I have a thread adding items to a BlockingCollection .
BlockingCollection
On another thread I am using foreach (var item in myCollection.GetConsumingEnumerable())
foreach (var item in myCollection.GetConsumingEnumerable())
Possibly use the overload of GetConsumingEnumerable that takes a CancellationToken; then, if anything goes wrong from the producing side, it can cancel the consumer.
GetConsumingEnumerable
CancellationToken