Task.Factory.StartNew线程的优先级降低 [英] lowering priority of Task.Factory.StartNew thread
本文介绍了Task.Factory.StartNew线程的优先级降低的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
一个code像下面将开始一个新的线程来完成这项工作。有没有什么办法可以控制线程的优先级?
Task.Factory.StartNew(()=> {
//这里的一切都将在一个新的线程中执行。
//我想设置该线程BelowNormal的优先级
});
解决方案
这是不,当你决定是否使用线程池与否之一; - )
更多细节在这里: http://msdn.microsoft.com/en-美国/库/ 0ka9477y.aspx
因此,答案是不,你不能在Theads池创建的线程指定特定的优先级
由于普通螺纹的我敢打赌,你已经知道 Thread.Priority 财产
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 ;-)
More details here: http://msdn.microsoft.com/en-us/library/0ka9477y.aspx
So the answer is "No, you cannot specify particular priority for thread created in Theads Pool"
As of general threadings I bet you already know about Thread.Priority property
这篇关于Task.Factory.StartNew线程的优先级降低的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文