当关闭Windows窗体时,该进程仍在运行 [英] When close Windows Form, the process still running

查看:79
本文介绍了当关闭Windows窗体时,该进程仍在运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI,
我又遇到问题了.
我创建了Windows窗体程序.我正在使用WCF.
主机->控制台应用程序
客户-> Windows窗体

当我关闭客户端时,在Windows任务管理器的进程"选项卡中,它仍在运行(ClientForm).当我单击结束进程"时,它不会关闭,只有在单击结束进程树"时,它才起作用!
一切都应该没问题,但是当我再次打开客户端"表单时(在Win.Task Manager中,它取名为ClientForm(1)),并且从"ClientForm"中接受了一些参数.

我该如何解决此问题?

再次感谢! :)
请留在这篇文章中,我将在早晨在拉脱维亚进行评论,现在是晚上2:45! :)


I have again a problem.
I''m created a Windows Form program. I''m using WCF.
Host -> console application
Client -> windows form

when i close Client, on Windows Task Manager in the Processes tab it still running(ClientForm). When i click ''End process'' it don''t shut down, it dos only if I click End process tree!
All should be ok, but when I open Client form again (In Win. Task Manager it takes Name ClientForm(1)), and it takes some arguments from ClientForm.

how I can fix this problem?

Thanks, again! :)
please stay with this post, I will review in morning in Latvia now is 2:45 at night! :)

推荐答案

您如何关闭表格?当您似乎要从控制台应用程序实例化表单时,它可能仍然保留对表单的引用.
也许代码段会有用.
How are you closing your form? As you seem to be instantiating the form from the console app it may still retain reference to your form.
Perhaps a code snippet would be useful.


瓦尔扎,

可能是因为您启动了不是backgound线程的某个线程.不是后台线程的线程会阻止应用程序退出.你能检查一下吗?

干杯

Manfred
Hi Valza,

could it be that you started some thread that was not a backgound thread. Threads that are not background threads keep an application from exiting. Can you check that?

Cheers

Manfred


如果您使用控制台应用程序生成表单,您可能仍需要显示主机(控制台应用程序)的片段.
根据您发布的代码,我将检查以下内容:

1.确保在调用this.Close()时,"this"引用指向ClientForm.尝试放置断点,并在关闭表单时查看调试时会发生什么情况.

2.当您调用this.Hide()来隐藏ClientForm并显示TestuForm时,关闭应用程序时可能只关闭了TestuForm,而没有关闭ClientForm.您是否在TestuForm的表单上附加了一个事件.已关闭以同时关闭ClientForm?
简而言之,请确保从用户界面关闭应用程序时调用"this.Close()".

app.config很可能只是一个警告,不应影响您的表单关闭问题.
You probably will still need to show a snippet of your Host (console app) if you are using a console app to spawn the form.
Based on the code you have posted I''d check the following:

1. Make sure when you call this.Close() the "this" reference is referring to ClientForm. Try putting breakpoints and see what happens when you debug this when closing the form.

2. As you called this.Hide() which hides the ClientForm and shows TestuForm it is possible when you closed the application you only closed TestuForm but not ClientForm. Did you attach an event to TestuForm''s Form.Closed to also close ClientForm?
In short, make sure the "this.Close()" is called when you close your app from the user interface.

The app.config is most likely just a warning and shouldn''t affect your form closing issue.


这篇关于当关闭Windows窗体时,该进程仍在运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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