I use the Action<object>.BeginInvoke()
method, does this use the thread pool or not?
我使用Action
I have the following C# code:
我有以下C#代码:
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?
是否在幕后使用线程池?或者系统是否创建正常线程?
1 个解决方案
#1
Yes this work will occur in the thread pool. This page in MSDN goes into depth on how BeginInvoke works:
是的,这项工作将在线程池中进行。 MSDN中的这个页面深入介绍了BeginInvoke的工作原理:
#1
Yes this work will occur in the thread pool. This page in MSDN goes into depth on how BeginInvoke works:
是的,这项工作将在线程池中进行。 MSDN中的这个页面深入介绍了BeginInvoke的工作原理: