You can change the scheduling priority of a running process to a value lower or higher than the base scheduling priority by using the renice command from the command line. This command changes the nice value of a process.
If you set priority to low, it will only run, when nothing else with higher priority is running, resulting in more responsive GUI. Generally programs that should have this tweaked such as video editing apps (VirtualDub) or renderers offer this.
Try setting the PriorityClass AFTER you start the process. Task Manager works this way, allowing you to set priority on a process that is already running.
You can create a process with lower priority by doing a little hack. You lower the parent process priority, create the new process and then revert back to the original process priority:
var parent = Process.GetCurrentProcess();
var original = parent.PriorityClass;
parent.PriorityClass = ProcessPriorityClass.Idle;
var child = Process.Start("cmd.exe");
parent.PriorityClass = original;
child
will have the Idle
process priority right at the start.
If you're prepared to P/Invoke to CreateProcess
, you can pass CREATE_SUSPENDED
in the flags. Then you can tweak the process priority before resuming the process.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With