降低 Task.Factory.StartNew 线程的优先级 [英] lowering priority of Task.Factory.StartNew thread

查看:34
本文介绍了降低 Task.Factory.StartNew 线程的优先级的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

像下面这样的代码将启动一个新线程来完成这项工作.有什么办法可以控制那个线程的优先级吗?

a code like below will start a new thread to do the job. Is there any way I can control the priority of that thread?

Task.Factory.StartNew(() => {
    // everything here will be executed in a new thread.
    // I want to set the priority of this thread to BelowNormal
});

推荐答案

当你决定是否使用线程池时,这是不要做"之一;-)

This is one of "not to do" when you decide whether to use thread pool or not ;-)

更多详细信息:http://msdn.microsoft.com/en-我们/图书馆/0ka9477y.aspx

所以答案是不,您不能为在 Theads Pool 中创建的线程指定特定的优先级"

So the answer is "No, you cannot specify particular priority for thread created in Theads Pool"

对于一般线程,我敢打赌您已经了解 Thread.Priority 属性

As of general threadings I bet you already know about Thread.Priority property

这篇关于降低 Task.Factory.StartNew 线程的优先级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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