killing off threads when a program exits?

fguihen

Well-known member
Joined
Nov 10, 2003
Messages
248
Location
Eire
i have 2 threads running in my c# application. the only exit button on the program is the X in the top right corner. is thare any method or deligate that i can call upon when the program is being closed, to kill of any threads running in memory? do you have to kill off timers also, since they are very similar to threads?
 
set all treads to run in background
(name. IsBackground = 1)
will do they will terminate when the application ends.
 
Timers will kill off themselves, since they are merged into your forms. You could double check that none of your threads are running in your form_unload event (sorry dont know the c# equivalant) and close any that are still running to be doubly sure.
 
the timers i use arnt System.Windows.forms.timers. theyre system.timers. different animals altogether. the forms.timers are not safe in a multithreadded envrionment.
 
If the threads should terminate along with the rest of the application, then set the Thread.IsBackground property as mentioned by Jorge above.
 
Back
Top