开发者

quiting a c# application leaves it in memory

I'm u开发者_StackOverflow中文版sing c# to write a windows form which installs and deploys WSPs to a sharepoint server. The problem I am having is that when I detect a problem and quit the application or when the cross in the top right of the form is pressed the form closes but the task is still in the process list.

My quit code is:

this.close();
application.quit();

The way i change between forms is:

form2.show();
form1.hide();

My only guess so far is that I use a few background workers, possibly these are not being terminated at the same time?

Thanks


The process terminates when all threads that are not set as background threads terminate.

BackgroundWorker internally calls BeginInvoke on a delegate and that causes the code to be run a thread from the ThreadPool. The ThreadPool threads have IsBackground set to true, so it should not cause the application to hang. It is unlikely that a BackgroundWorker is causing the problem.

More likely, you have a place in your code where you are manually creating a new thread using new Thread() or similar and you have not set this thread's IsBackground member to true.


It should be pretty easy to attach a debugger (you can get the Managed Stack Explorer if you don't have a debugger on the machine exhibiting the problem) and you can break into the process to see which threads are currently executing. In Visual Studio you should look in the Threads window and find one that's executing your code. Double click it, then look in the Call Stack window to see what's holding things up.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜