i am looking for a way to : 1. read messages from a ConcurentQueue limited to some size. 2. read not more then X message at a time frame. i want to stop the reading from Q once one of the 2 hit, until other code is done and do the same thing again.
i saw different implementation for Queue spill over, in here Fixed size queue which automatically dequeues old values upon new enques but can t figure out how to combine them correctly.
public class FixedSizedQueue<T>
public int Size { get; private set; }
public FixedSizedQueue(int size)
{
Size = size;
}
public void Enqueue(T obj)
{
queue.Enqueue(obj);
while (queue.Count > Size)
{
T outObj;
queue.TryDequeue(out outObj);
}
}
}