Hi All, I have a Console EXE which calls a Thread...inside its module. I
want to spawn the thread in such a way that if the console.exe is killed, my
thread keeps on running ...until it finishes up
TIA
In most of my applications, I usually am trying to make sure my
threads are gone ASAP, so this is a new one to me. The times when my
thread DOESN'T go away immediately, I have "IsBackground" is set to
false.
Then on the app-exit or the module dispose event, call
YourThread.Join(X) where X is a valid number of seconds to wait before
disposing the threads entirely.
The catch with this, I've found is that most of the time it will wait
EXACTLY X milliseconds, even if the threads are all gone.
An even better method might be to keep an ArrayList of running threads
in the module. On module dispose, While ArrayList.Count > 0,
Thread.Sleep(...) for a small slice of time. For safety, I'd put a max
counter in there to ke your app from hanging indefinately. But that's
probably just me being paranoid about runaway processes.
There may be an even slicker solution to this, but that's just my
suggestion. Hope it helps.
--Sim