如何从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);
}