System.Collections.Generic.Queue does not have a TryDequeue method, however its Dequeue is a throwing method so the following pattern always has to be used:
T item ...;
if (queue.Count > 0)
{
item = queue.Dequeue();
...
}
with extra boilerplate for for whatever no item handling; this would be better as:
T item;
if (queue.TryDequeue(out item)
{
...
}
As per ConcurrentQueue or TryGet of Dictionary
System.Collections.Generic.Queuedoes not have aTryDequeuemethod, however itsDequeueis a throwing method so the following pattern always has to be used:with extra boilerplate for for whatever no item handling; this would be better as:
As per
ConcurrentQueueorTryGetof Dictionary