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/