通常我聽說有25個線程在ThreadPool上運行。C#-Findinding主題
當我執行以下命令:
namespace Examples.Delegates
{
public delegate void InvokerDelegate();
class Discussion
{
static void Main()
{
Discussion dis=new Discussion();
InvokerDelegate MethodInvoker=dis.Foo;
for(int i=1;i<=30;i++)
{
MethodInvoker.BeginInvoke(null,null);
}
Console.ReadKey(true);
}
private void Foo()
{
int avlThreads, avlToAsynThreads;
ThreadPool.GetAvailableThreads
(out avlThreads,out avlToAsynThreads);
string Message=string.
Format("From ThreadPool :{0} ,Thread Id :{1},Free Threads :{2}",
Thread.CurrentThread.IsThreadPoolThread,
Thread.CurrentThread.ManagedThreadId,
avlThreads);
Console.WriteLine(Message);
Thread.Sleep(1000);
return;
}
}
}
「消息」(即)avlThreads打印490+提供threads.What 被修正,我應該需要做的字符串的第三個參數?
是的,我的是.NET 3.5上的雙處理器 – user215675 2009-11-24 07:57:46