using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Collections.Concurrent; namespace Aitex.DataAnalysis.Core { public class FixSizeQueue : ConcurrentQueue { public int FixedSize { get; private set; } public FixSizeQueue(int size) { FixedSize = size; } public new void Enqueue(T obj) { base.Enqueue(obj); lock (this) { while (base.Count > FixedSize) { T outObj; base.TryDequeue(out outObj); } } } } }