|Here are some facts:
By themselves, threads stay alive as long as they have something to do; most likely this
means they are inside a loop (could be a message loop as inside Application.Run, and
in Form.ShowDialog) or they are waiting on something that has not happened yet (such as
From outside the thread, a thread could get aborted or killed, to make it stop.
When Thread.IsBackground is true, then that thread will not prevent the app from exiting.
And some suggestions:
- watch your CPU activity (Windows Task Manager, Processes, column: CPU); if not near zero,
your app is still busy (calculating, or looping, anything that exceeds waiting)
- if CPU is near 100% you are probably stuck inside a loop that contains no wait, and also
no delay (something like a polling loop without a Thread.Sleep; a very bad idea!)
- add logging to your threads
- make sure you do not eat Exceptions; they are there for a purpose, act on them, dont
just catch and ignore them
- use Visual Studio to observe and debug your app
- try and avoid potential deadlocks (you know, the situation where multiple threads need
access to the same resources, which are protected in some way, say by locks;
thread 1 grabs resource 1 then tries to grab resource 2, whereas thread 2 grabs
resource 2 then tries to grab resource 1.). If this is too mysterious, find yourself
some articles on the subject (and again add logging to your app, with logging you pretty soon
should notice a deadlock if and when it happens.