Traditional C++ Windows threading was easy - the HANDLES could be saved when creating the threads so you could kill them or WaitForSingle/Multiple Object to know when one dies, etc.
In .NET, I'm torn between battling the ThreadPool class or creating my own - but I'm stuck on some seemingly simply tasks:
1. Using the threadpool, how do I kill a thread created using the QueueUserWorkItem method? (sometimes my threads can hang)
2. How do I walk all my threads created (above) & determine which are hanging if any (so that I can kill them if needed)
3. If I roll my own threadpool class, how do I monitor threads to know when they complete - without putting extra code/logic into the thread itself (ie I want to be able to use a thread without having to use special signalling etc.) The Thread and ProcessThread classes don't seem to overlap...???
Any help???
zabutimaxim@gmail.com - 17 Apr 2005 15:08 GMT
If you want to monitor threads use array of events
and check their state. But if you want to simulate WaitForSingleObject
use Thread.Join, that will pass after thread finished.
Hope this helps