internal void Run()
{
try
{
while(true)
{
lock(this.mutex)
{
pending = false;
if(this.shutdown)
{
return;
}
}
if(!this.Iterate())
{
// wait to be notified.
lock(this.mutex)
{
if(this.shutdown)
{
return;
}
while(!this.pending)
{
Monitor.Wait(this.mutex);
}
}
}
}
}
catch(ThreadAbortException)
{
Thread.ResetAbort();
}
catch
{
}
finally
{
// Make sure we notify any waiting threads that thread
// has terminated.
lock(this.mutex)
{
this.terminated = true;
Monitor.PulseAll(this.mutex);
}
}
}