Jon
Jon

Reputation: 40032

Does BlockingCollection.GetConsumingEnumerable() remove items

Can someone confirm that the below code definitely removes items from the BlockingCollection

foreach (var item in myCollection.GetConsumingEnumerable())
{
  //Do stuff
}

It does say on MSDN that it does but I just need to be re-assured as I have a near real time application accepting inputs into 4 of these collections 60ms apart and after a while my app is freezing and I dont know why and just wanted to be sure that items are being removed.

Upvotes: 4

Views: 1087

Answers (1)

SLaks
SLaks

Reputation: 887469

The documentation says:

Return value:
An IEnumerable that removes and returns items from the collection.

(emphasis added)

Upvotes: 5

Related Questions