How to empty a BlockingCollection

前端 未结 6 2244
闹比i
闹比i 2021-02-18 21:34

I have a thread adding items to a BlockingCollection .

On another thread I am using foreach (var item in myCollection.GetConsumingEnumerable())

6条回答
  •  南方客
    南方客 (楼主)
    2021-02-18 21:47

    BlockingCollection yourBlockingCollection = new BlockingCollection();
    

    I assumed you mean clear your blocking collection. Jon's answer is more appropriate to your actual question I think.

提交回复
热议问题