Thread-safe blocking queue implementation on .NET

后端 未结 7 806
無奈伤痛
無奈伤痛 2020-12-15 07:28

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

7条回答
  •  醉酒成梦
    2020-12-15 08:03

    For the reference, .NET 4 introduces the System.Collections.Concurrent.BlockingCollection type to address this. For non-blocking queue, you can use System.Collections.Concurrent.ConcurrentQueue. Note that ConcurrentQueue would likely be used as the underlying datastore for the BlockingCollection for the OP's usage.

提交回复
热议问题