.net - 当 ThreadPool.QueueUserWorkItem 返回 false

标签 .net multithreading concurrency threadpool

MSDN 指出该方法返回

true if the method is successfully queued; NotSupportedException is thrown if the work item is not queued.



出于测试目的,如何获取返回 false 的方法?或者它只是一个“次优”的类设计?

最佳答案

在查看 Reflector 中的源代码时,似乎代码中唯一可能返回“false”的部分是对以下内容的调用:

[MethodImpl(MethodImplOptions.InternalCall)]
private static extern bool AdjustThreadsInPool(uint QueueLength);

关于.net - 当 ThreadPool.QueueUserWorkItem 返回 false,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/150645/

相关文章:

c# - 如何从 TestCleanup 方法中获取测试名称?

c# - 在 C# 控制台应用程序中编辑文本?

c# - 如何在 64 位操作系统中注册 activeX 组件(.dll)

Azure 数据工厂并发性和依赖性

c# - 将电子邮件附件保存到 UNC 路径

c++ - 将 OpenMP 与 C++ 结合使用的算法库

java - 我如何调用线程本身?

c++ - 一个线程设置成员,而另一个循环遍历它 - 这是线程不安全的吗?

Java 应用程序在使用 synchronized 关键字时卡住

java - 这应该是不稳定的还是结果不可预测?