using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Chrosey.Extensions.Wrapper { public class ConcurrentQueueWrapper { private readonly ConcurrentQueue queue = new ConcurrentQueue(); public event EventHandler Changed; protected virtual void OnChanged() { if (Changed != null) Changed(this, EventArgs.Empty); } public virtual void Enqueue(T item) { queue.Enqueue(item); OnChanged(); } public int Count { get { return queue.Count; } } public virtual bool TryDequeue(out T item) { if (queue.TryDequeue(out item)) { OnChanged(); return true; } return false; } } }