C#, IAsyncResult and the thread pool
I use the Action<object>.BeginInvoke()
method, does this use the thread pool or not?
I have the following C# code:
List<FileHash> hashList1 = hashList.Where((x, ind) => ind % 2 == 0).ToList();
List<FileHash> hashList2 = hashList.Where((x, ind) => ind % 2 == 1).ToList();
Action<object> oddWork = CalcHash;
Action<object> evenWork = CalcHash;
IAsyncResult evenHandle = evenWork.BeginInvoke(hashList1, null, null);
IAsyncResult oddHandle = oddWork.BeginInvoke(hashList2, null, null);
evenWork.EndInvoke(evenHandle);
oddWork.EndInvoke(oddHandle);
Is the thread pool used behind the scenes or not? Or does the system create normal threads?
Yes this work will occur in the thread pool. This page in MSDN goes into depth on how BeginInvoke works:
http://msdn.microsoft.com/en-us/library/2e08f6yc.aspx
链接地址: http://www.djcxy.com/p/52842.html上一篇: 用标准(Obj sender,EventArgs args)签名创建事件处理程序委托有多大错误?
下一篇: C#,IAsyncResult和线程池