Please see my comment to the question. Even though it is not 100% clear to me, but this looks like a general problem of the producer-consumer pattern: [Sorry, we are experiencing the problem of broken anchors in CodeProject posts; please use:
http://en.wikipedia.org/wiki/Producer%E2%80%93consumer_problem;
sorry for the inconvenience].
The class
BlockingCollection<T>
offers
bounding (not to be confused with the notion of
binding):
BlockingCollection<t> is a thread-safe collection class that provides the following:
[…]
A bounded collection that blocks Add and Take operations when the collection is full or empty.
Please pay attention for these constructors defining bounding:
http://msdn.microsoft.com/en-us/library/dd267301(v=vs.110).aspx[
^],
http://msdn.microsoft.com/en-us/library/dd267306(v=vs.110).aspx[
^]
and for this member:
http://msdn.microsoft.com/en-us/library/dd287159(v=vs.110).aspx[
^].
See also:
How to: Add Bounding and Blocking Functionality to a Collection.
As to the "replacing" (why?), consider adding and the methods named
Skip*
.
—SA