views:

64

answers:

1

Hello,

If you are reading this (hoping you will be able to help me!), you most probably know that 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
});

Thanks :)

+1  A: 

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

zerkms
Yes I know about Thread.Priority. But I just wanted to know if it was possible with Task Factory instead of using objects of Thread.
Ruby
At the first link it is description that said that it is not possible with Task Factory. Anyway I never need to change priority for threads from pool and not 100% sure that it is truth.
zerkms