How can I/O priority of a process be increased?

后端 未结 6 548
别跟我提以往
别跟我提以往 2020-12-13 16:33

I want to increase the I/O priority of a process. Answers for both .NET and Windows Vista would be nice. processexplorer is ok as well.

6条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-13 17:13

    Just an update for this - it can all be done via .NET without resorting to WinAPI ...

    // Set the current process to run at 'High' Priority
    System.Diagnostics.Process process = System.Diagnostics.Process.GetCurrentProcess();
    process.PriorityClass = System.Diagnostics.ProcessPriorityClass.High;
    
    // Set the current thread to run at 'Highest' Priority
    Thread thread = System.Threading.Thread.CurrentThread;
    thread.Priority = ThreadPriority.Highest;
    

    I've tried the above setting the process priority in a WPF application and it works fine. Haven't needed to set thread priority.

    EDIT: this above relates to CPU priority of a process, as opposed to I/O priority, however there may be some correlation / connection between a process's CPU priority and its I/O priority.

提交回复
热议问题