Click here to Skip to main content
15,879,095 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I use threading and exception handling in my windows program.

My program have several threads and when any exception raise then i exit from the application using Application.Exit().

But all threads does not close, several threads are still running.

So how to close all threads when program exit due to exception.
Posted

Hi,

Please have a look at the following:

HOWTO: Stop Multiple Threads[^]
List Threads[^]

Kind regards,
 
Share this answer
 
Your main thread should know about all the child threads being created. The easiest would be to have a thread manager class that maintains references to all the running threads and can then be called to kill all the active ones.
 
Share this answer
 
You could use the oft-ignored detructor and abort threads in the objects that created them. Of course, that's more like being a real programmer than most want to actully attempt.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900