Need best way to terminate multiple threads immediately (Suspend is now obsolete)
Posted on 2007-08-10
I have a class which starts up a timer. Each time the timer goes off, the program grabs a bunch of records from a database. It splits those records up among five arrays, and spawns off five threads to process each array.
The class has a shutdown method which suspends and destroys the timer, then goes through and does a .Suspend on each thread which is running.
.NET is telling me that .Suspend is obsolete, which I assume means I'm not supposed to use it, but then all it tells me is that I'm supposed to use Monitor, Mute, Event or Semaphore instead, but it doesn't give me any idea of how to do that.
All I want to do is loop through the array of pointers to the threads and shut each of them down. Can anybody tell me a quick and clean way to do that?