It seems there are lots of improvements in .NET 4.0 related to concurrency that might rely on concurrent priority queues. Is there decent priority queue implementation insid
Check Thread-safe Collections in .NET Framework 4 and Their Performance Characteristics but AFAIK there are no ready to use priority queue. All new thread-safe collections doesn't maintain order but you can make your own on top of them. Check @Steven's way.
I've found a great example of a concurrent priority queue here. Hope it will help you a little.
var priorityQueue = new ConcurrentPriorityQueue<TKey, TValue>();
TKey in the context of this queue could be an int value or any other object that implements IComparable.
For consuming such a queue you may do a following:
var priorityQueue = new ConcurrentPriorityQueue<int, object>();
// Add elements
priorityQueue.Enqueue(2, elementP2);
priorityQueue.Enqueue(1, elementP1);
// Here you will receive elementP1
bool result = priorityQueue.TryDequeue(out KeyValuePair<int, object> element);
Well, 7 years passed, but for posterity, I would like to answer with my implementation.
Documentation: Optionally awaitable simple to use Concurrent Priority Queue
Sourcecodes: github
nuget package