C#,IAsyncResult的和线程池 [英] C#, IAsyncResult and the thread pool

查看:355
本文介绍了C#,IAsyncResult的和线程池的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用动作<对象> .BeginInvoke()方法,这是否使用线程池或没有?

I use the Action<object>.BeginInvoke() method, does this use the thread pool or not?

我有以下的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?

推荐答案

是的这项工作将发生在线程池。该页面在MSDN进入深入的BeginInvoke如何工作的:

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

这篇关于C#,IAsyncResult的和线程池的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆