如何在Winform应用程序堆栈中终止进程? [英] How Do I Terminate The Processes In Winform Application Stack?

查看:89
本文介绍了如何在Winform应用程序堆栈中终止进程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的解决方案中,我有2个项目

1- winform应用程序

2- windows服务应用程序



该服务可以通过套接字编程实现许多工作并通知其进展。

似乎服务运行速度如此之快,但winform并不像服务那么快。

所以停止服务后winform仍在工作!! (增加进度条,更新文本框,列表视图等)



如果在表单仍处于打开状态并且还准备就绪时服务停止后如何强制winform进程停止再次启动服务后获得新的操作。



In my solution i have 2 projects
1- winform application
2- windows service application

the service does many works and informs the progress to winform by socket programming.
it seems the service works so fast but winform is not as fast as service.
so after stopping the service the winform is still working !! (increments progressbar, updating textbox, listview and so on)

how can i force winform processes to stop after the service is stopped while the form is still open and also ready to get new operations after starting the service again.

if (service.Status == ServiceControllerStatus.Stopped)
{
/// Stop winform painting or Clear stack or queue
}

推荐答案

我不理解其他人的一些建议。停止处理,关闭表格 - 这不是你的问题。如果你一直观察到这种行为,你就会在这里遇到严重的竞争状态。因此,您可以发送消息以删除所有进一步的处理(如果您的当前解决方案可以实现),或者找到其他方式(可能不会更新服务中每个信号的表单,而是记录它们一个队列/列表并在常规Intervalls中更新表单。或者你可以增加你的周期时间等。
I don't understand some advices by others. Stopping processing, closing Form - that's not your problem. You semm to have a servere race condition here if you observe this behavior all the time. So you maybe could send a message to drop all further processing (if this is possible with your current solution), or find another way (may don't update the form on every "signal" from your Service, but "record" them in a Queue/list and update the form in regular Intervalls. Or maybe you can increase your "cycletime", etc.


向Win Forms应用程序发送一条消息告诉它退出。 />


您显然已经知道如何在这些应用程序之间发送消息,因此只需在协议中添加另一条消息。
Send a message to the Win Forms app telling it to quit.

You obviously already know how to send a message between those applications, so just add another message to your protocol.


这篇关于如何在Winform应用程序堆栈中终止进程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆