且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

启用队列<T>并发

更新时间:2022-05-06 15:51:02

您在将项目入队时将其出队.
您需要使用您的参数引发事件.

You're dequeueing your items as you enqueue them.
You need to raise the event using your parameter.

它是否真的是线程安全的取决于你如何使用它.
如果您曾经检查过 Count 或检查是否为空,则它不是线程安全的,也不能轻易地成为线程安全的.
如果你不这样做,你可能可以使用比队列更简单的东西.

Whether it's actually thread-safe depends on how you use it.
If you ever check the Count or check for emptiness, it's not threadsafe and cannot easily be made threadsafe.
If you don't, you can probably use something simpler than a queue.