<"Alvin Bruney [MVP]" <vapor at steaming post office>> wrote:
> I'd recommend you use the threadpool.
>
> Otherwise, you will have to store the taskThread reference on a stack
> somewhere and then loop the items in this list (after the start()) call
> examining the each thread. The reference will allow you access to the
> executing thread. You then need to modify your PerformTask routine to
> examine global/static flags so that you can cause them to go to sleep etc.
hile I would agree that using thread pools is a generally good idea,
I'd personally recommend against using the built-in system thread pool,
usually. It's very easy to end up in deadlock situations if your thread
pool tasks use (often without your knowledge) other thread pool threads
- and if you have enough threads waiting for other thread pool threads
to do something, you deadlock.
If you use a custom thread pool which is entirely separate, you can't
run into this problem as easily.
There are plenty of custom thread pool classes around - I have one in
my (free) MiscUtil library at
http://www.pobox.com/~skeet/csharp/miscutil
(I must write more about this problem in my threading article some
time... along with stuff about Thread.Abort etc!)
--
Jon Skeet - <(E-Mail Removed)>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too