Search code examples
c#.netmultithreading.net-4.0taskfactory

lowering priority of Task.Factory.StartNew thread


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
});

Solution

  • 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