我试图绕过的wait64句柄限制是.NET 3.5的规定线程池 - 为WaitAll 64句柄限制
我已经看到了这个线程:Workaround for the WaitHandle.WaitAll 64 handle limit?
所以我了解大致的构想,但我有困难因为我没有使用一个委托,而是
我基本上是工作的这个例子: http://msdn.microsoft.com/en-us/library/3dasc8as%28VS.80%29.aspx
此链接http://www.switchonthecode.com/tutorials/csharp-tutorial-using-the-threadpool 是相似的,但同样保持任务跟踪的int变量是一个成员变量。
在上面的例子中,我会传递threadCount整数吗? 作为对象在回调方法中传递它吗?我认为我遇到了回调方法和参考传递的问题。
谢谢斯蒂芬,
该链接是不完全清楚的我。
让我后我的代码,以帮助自己澄清:
for (int flows = 0; flows < NumFlows; flows++)
{
ResetEvents[flows] = new ManualResetEvent(false);
ICalculator calculator = new NewtonRaphson(Perturbations);
Calculators[flows] = calculator;
ThreadPool.QueueUserWorkItem(calculator.ThreadPoolCallback, flows);
}
resetEvent.WaitOne();
我会在哪里掠过我的THREADCOUNT变量。我认为它需要在calculator.ThreadPoolCallback中递减?
什么是numTask整数? – 2010-06-30 19:22:05
对不起,我相信我的意思是来自第一个链接的“threadCount”。 – bearrito 2010-06-30 19:31:45
次要技术问题:64句柄限制是由Win32 API而不是.NET 3.5强加的。所以,Windows上的每个程序都有相同的限制。 – 2010-06-30 19:34:17