Try Dequeue in ConcurrentQueue

C-va picture C-va · Feb 16, 2011 · Viewed 24k times · Source

The TryDequeue in ConcurrentQueue will return false if no items in Queue.

If the Queue is empty I need that my queue will wait until new item to be added in queue and it dequeue that new one, and the process will continues like that.

Should i use monitor.enter,wait,pulse or any better options in C# 4.0

Answer

Damien_The_Unbeliever picture Damien_The_Unbeliever · Feb 16, 2011

Isn't this what BlockingCollection is designed for?

As I understand it, you can wrap your ConcurrentQueue with one of these, and then call Take.