public void Wakeup()
{
lock(runable)
{
// When we get in here, we make some assumptions of state:
// queued=false, iterating=false: wakeup() has not be called and
// therefore task is not executing.
// queued=true, iterating=false: wakeup() was called but, task
// execution has not started yet
// queued=false, iterating=true : wakeup() was called, which caused
// task execution to start.
// queued=true, iterating=true : wakeup() called after task
// execution was started.
if(queued || _shutdown)
{
return;
}
queued = true;
// The runTask() method will do this for me once we are done
// iterating.
if(!iterating)
{
ThreadPool.QueueUserWorkItem(new WaitCallback(Run), this);
}
}
}