in src/main/csharp/Util/MessageDispatchChannel.cs [159:188]
public MessageDispatch Dequeue(TimeSpan timeout)
{
MessageDispatch result = null;
this.mutex.WaitOne();
// Wait until the channel is ready to deliver messages.
if( timeout != TimeSpan.Zero && !Closed && ( Empty || !Running ) )
{
// This isn't the greatest way to do this but to work on the
// .NETCF its the only solution I could find so far. This
// code will only really work for one Thread using the event
// channel to wait as all waiters are going to drop out of
// here regardless of the fact that only one message could
// be on the Queue.
this.waiter.Reset();
this.mutex.ReleaseMutex();
this.waiter.WaitOne((int)timeout.TotalMilliseconds, false);
this.mutex.WaitOne();
}
if( !Closed && Running && !Empty )
{
result = DequeueNoWait();
}
this.mutex.ReleaseMutex();
return result;
}