Fast and Best Producer/consumer queue technique BlockingCollection vs concurrent Queue [closed]
Want to improve this question? Update the question so it can be answered with facts and citations by e开发者_Python百科diting this post.
Closed 8 years ago.
Improve this questionIm using Generic.Queue in C# 3.0 and Monitor.Enter,wait,exit for wait before consuming the queue (wait for the element to be enqueued). Now im moving to C# 4.
Can anyone suggest me which one is fast and best especially to avoid locks..
BlockingCollection vs concurrentQueue or any thing else...
Note. I dont want to restrict my producer
Thanks in advance..
BlockingCollection
and ConcurrentQueue
are there for precisely this reason. I doubt that you'll find anything better, or simpler to use. The parallel extensions team know their stuff :)
Just a quick check on versions though - you're definitely using .NET 4, not just C# 4? (For example, you could be using Visual Studio 2010 and thus C# 4, but still targeting .NET 3.5, in which case you couldn't use Parallel Extensions.)
You may also want to start researching Task-Based Asynchronous Pattern, TPL Dataflow and the async/await features of C# 5... obviously you can't use them just yet, but it doesn't hurt to know what's coming up.
精彩评论