Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
C# 中是否存在与 ConcurrentBag 的非并发类比?我需要创建一个 concurrentBag 的快照,所以我需要一个浅拷贝并且我不需要线程安全。请注意,concurrentbag 可以包含重复项。
谢谢
也许更接近的类比是创建一个Queue<T>,因为它支持采取(Dequeue方法)。
Queue<T>
Dequeue
ConcurrentBag<MyType> bag = new ConcurrentBag<MyType>(); // create a queue Queue<MyType> q = new Queue<MyType>(bag);