.NET 6 now has PriorityQueue<TElement,TPriority> which is very useful. The document is not very clear yet (granted at the time of the question the documentation is still for RC1) if it is thread-safe or not. Two things:
It resides in
System.Collections.Generic
and there doesn't seem to be an equivalent inSystem.Collections.Concurrent
.It does have method named
TryDequeue
andTryPeek
. Granted they probably are just methods that do not throw exception when the queue is empty but it does give an impression of the concurrent collections.
Can I use it for multithreaded environment without wrapping/locking (for example in an ASP.NET Core website)? Any concurrent equivalent that I am not aware of (I try not to use 3rd-party package if possible)?