public MessageDispatch Dequeue(TimeSpan timeout)
{
lock(this.mutex)
{
// Wait until the channel is ready to deliver messages.
if( timeout != TimeSpan.Zero && !Closed && ( Empty || !Running ) )
{
Monitor.Wait(this.mutex, timeout);
}
if( Closed || !Running || Empty )
{
return null;
}
return RemoveFirst();
}
}