public override T1 Dequeue(int millisecondsTimeout) { using (ChoBarrier lowBarrier = ChoBarrier.LowBarrier(_barrier)) { if (!lowBarrier.Wait(millisecondsTimeout)) { throw new ChoQueueTimeoutException(); } T1 item = _queue.Dequeue(); return(item); } }
public override T1 Dequeue(int millisecondsTimeout) { lock (_syncRoot) { while (_queue.Count == 0) { try { if (!Monitor.Wait(_syncRoot, millisecondsTimeout)) { throw new ChoQueueTimeoutException(); } } catch { Monitor.PulseAll(_syncRoot); throw; } } T1 item = _queue.Dequeue(); Monitor.PulseAll(_syncRoot); return(item); } }