Reputation: 6395
I need to terminate the running threads to shutdown application.
After executing common application exit commands, there are a few threads are still running, so application won't shut down completely (console window is still open).
I use code snippets which create those threads, so I can't control these threads. To kill them I need to modify the code and make a running threads collection like thing (long way) or get the -still- running threads and terminate them gracefully.
Now, how can I get the alive threads list in C#?
Upvotes: 1
Views: 171
Reputation: 2790
while creating threads, you can set thread.IsBackground = true
which terminates process event when they are not "finished" (when all non-background threads are).
more: http://msdn.microsoft.com/en-us/library/system.threading.thread.isbackground.aspx
Upvotes: 2