I have an multithreaded application and I want to be able to use a timer to periodically check to see if all threads have finished before starting a new one, ie:
var checkStatusTimer = new System.Threading.Timer(new TimerCallback(CheckThreads), null, 10000, 10000);
This is as far as I've come. What would need to go in the CheckThreads Method to check to see if they're done? I was thinking of something along the lines of a function that checks them like:
foreach (Thread thread in Threads)
{
Thread t = thread;
if (t.ThreadState != ThreadState.Stopped)
return false;
}
Am I on the right track? is this the correct way to go about this? Or should I use a System.Timers.Timer instead? Also, the function form within I want to do this periodic check is static. Any help would be appreciated.