Hi I have the following problem,
when an application from which I started several threads crashes, the threads remain running and I can’t close / terminate them from task manager
is there a way to terminate only threads started from this app in the UnhandledException event?
I keep a dictionary of thread handles, part of the thread setup and termination (and killing) is to register and de-register in this dictionary. You can then use this to cleanup wherever you need it.
1 Like
Watchdog? Timeout and give up. A kind of reverse watchdog.
You must create some kind process depending on the health of the main thread, the watchdog, that will “ping” each thread loops.
Each thread that runs infinitely doing something receives some kind of “ping” from, let’s say, a timer, lets say, every 10 secs. Timers are “main thread dependent”, if the main thread locks up, pings should end. If a ping does not come in 20 secs the watchdog is dead and threads should detect such condition and gracefully end.
This works even for remote processes, not only threads.
1 Like