lowering priority of Task.Factory.StartNew thread

后端 未结 4 1919
长发绾君心
长发绾君心 2020-12-01 05:15

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(() => {
    //          


        
4条回答
  •  醉梦人生
    2020-12-01 06:02

    For setting priority with Task, check out the custom task schedulers described by Microsoft expert Stephen Toub in this MSDN blog post. For further detail, don't miss the links to the previous two posts that he mentions in the first sentence.

    For your issue, it sounds like you might want to look at the QueuedTaskScheduler.

提交回复
热议问题