Setting thread priority to low(est)

  • Thread starter Thread starter Stu Banter
  • Start date Start date
S

Stu Banter

I have a couple of small single-thread Console utilities doing cpu-intensive
stuff. Is there an easy way to set the program execution priority to LOW
from within the program ? Now I pause the things first and invoke
TaskManager and manually set the priority... A bit cumbersome.
 
I don't think there is. You may want to execute the worker code in a
separate thread; that way you can control the priority. Good luck.
 
Use the Process class to GetCurrentProcess. Then use that process's
public property PriorityClass to set the priority of the process.
 
Hi,

Take a look at Process class, here you have a PriorityClass property that
you may use for it.

Also try this line:
Thread.CurrentThread.Priority = ThreadPriority.BelowNormal;


Hope this help,
 
Back
Top