I\'m looking for an implementation of thread-safe blocking queue for .NET. By \"thread-safe blocking queue\" I mean: - thread-safe access to a queue where Dequeue method cal
The Microsoft example is a good one but it is not encapsulated into a class. Also, it requires that the consumer thread is running in the MTA (because of the WaitAny call). There are some cases in which you may need to run in an STA (e.g., if you are doing COM interop). In these cases, WaitAny cannot be used.
I have a simple blocking queue class that overcomes this issue here: http://element533.blogspot.com/2010/01/stoppable-blocking-queue-for-net.html