I get back false from BlockingCollection's TryTake method, when the BlockingCollection is empty, although the expected behavior is to block until the collection fills up.
Note that the collection is not upper bounded (which should affect the TryAdd not the TryTake) and that the Timeout set for the add operation had not passed.
Here's my wrapper around the BlockingCollection object:
public T TryTake(int timeoutMiliseconds)
{
var result = default(T);
if (!_collection.TryTake(out result, timeoutMiliseconds))
{
throw new InvalidOperationException("Unable to get item from collection.");
}
return result;
}
Any ideas what can cause this ?
I've implemented the Producer-Consumer pattern, based on this article: Multithread processing of the SqlDataReader - Producer/Consumer design pattern