private void QueueProcessor(object unused)
{
Future theTask = null;
lock(syncRoot)
{
if(this.workQueue.Count == 0 || this.closing)
{
this.running = false;
this.executionComplete.Set();
return;
}
theTask = this.workQueue.Dequeue();
}
try
{
theTask.Run();
}
finally
{
if(this.closing)
{
this.running = false;
this.executionComplete.Set();
}
else
{
ThreadPool.QueueUserWorkItem(new WaitCallback(QueueProcessor), null);
}
}
}