如何从ConcurrentBag中删除所有项目?

问题描述:

如何清除 ConcurrentBag ?它没有任何方法清除 RemoveAll ...

How to clear the ConcurrentBag? it don't have any method like Clear or RemoveAll...

T someItem;
while (!myBag.IsEmpty) 
{
   myBag.TryTake(out someItem);
}