我試圖繞過的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