Added PredicateBuilder
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
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<T>
|
||||
{
|
||||
private readonly ConcurrentQueue<T> queue = new ConcurrentQueue<T>();
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user