Reputation: 2379
I have noticed when i run the VS.Net 2008 in debug mode after closing my mainwindow the debug mode used to stop automatically. But recently i have been using Threads and noticed after the main window closes VS.Net continues to stay in debug mode. Just wondering if this is expected or am i doing something wrong. Also in TaskManager the process seems to be live even after the MainWindow is closed. Please let me know if you have any idea. Thanks N
Upvotes: 0
Views: 1421
Reputation: 74802
Your threads probably have IsBackground = false. The process is prevented from terminating if there are still non-background threads running. So the UI thread is not the only thread that can keep the process alive.
To solve this problem, either set your worker threads' IsBackground to true (if you're happy for the .NET runtime to kill them when the main window closes), or terminate them yourself (e.g. during the Close event) if you want to be sure they are shut down in a predictable way.
Upvotes: 2