Click here to Skip to main content
15,886,783 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i create a thread..

but i don't know how to assign the priority to those threads..


can you help me...............
Posted

C#
Thread t = new Thread(() => { Console.WriteLine("Doing some work"); });
t.Priority = ThreadPriority.AboveNormal; //Assign priority here


Please atleast google for such simple questions.
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 30-Jun-11 5:10am    
My 5, but... people asking about changing priorities usually should not change them.
Please see my answer.
--SA
SetThreadPriority [^].
You'll find sample there
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 30-Jun-11 5:10am    
My 5, but... people asking about changing priorities usually should not change them.
Please see my answer.
--SA
I would warn you against changing priorities. First, it does not usually improve the program throughput. Think about it: you don't accelerate anything, you just use more of the CPU at the expense of other threads.

More importantly, usually an attempt to change priorities is the indication of incorrect use of threading and lack of knowledge of thread synchronization primitives. The rule is: if threading works incorrectly, changing of priorities cannot fix it.

—SA
 
Share this answer
 
Comments
Tarun.K.S 30-Jun-11 5:53am    
Hmm right, changing priorities can disturb other thread's operations. I was initially thinking of pointing that out, appreciate your answer. 5+
Sergey Alexandrovich Kryukov 30-Jun-11 13:43pm    
Thank you, Tarun.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900