Dequeue
using System.Collections.Generic; internal static class Utilities { internal static bool TryDequeue<T>(this Queue<T> queue, out T result) where T : class { lock (queue) { if (queue.Count == 0) { result = null; return false; } result = queue.Dequeue(); } return true; } }