TaskCreationOptions.LongRunning选项和线程池 [英] TaskCreationOptions.LongRunning option and ThreadPool

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

问题描述

TPL使​​用任务调度程序来协调任务。据正式文件,默认任务调度程序使用线程池,但是,如果 TaskCreationOptions.LongRunning 选项psented那么它会创建一个专用线程,该任务(A)。

TPL uses Task Schedulers to coordinate tasks. According to official document, default task scheduler uses Thread Pool, but if TaskCreationOptions.LongRunning option is presented then it will create a dedicated thread for that task (A).

问:截至目前MSDN文档为Visual Studio 2010还没有准备好和当前在线MSDN尚未敲定;没有任何人知道,如果(A)是真还是假?

Question: As of now MSDN documents for Visual Studio 2010 are not ready and current online MSDN is not finalized; does anyone knows if (A) is true or false?

推荐答案

LongRunning 强制创建池外一个新的线程。下面是最新的架构版本的一些伪拆解code:

Yes, LongRunning forces the creation of a new thread outside the pool. Here's some pseudo-disassembled code from the latest framework version:

...
if (task.Options HasFlag LongRunning) then
    create new Thread thread
    thread.Start(task)
...

编辑:从丑陋的C#转换为伪code

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

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