C# 进程优先级和线程优先级的方法
C# 设置进程优先级的方法
this.process1= Process.GetCurrentProcess();
process1.PriorityClass = ProcessPriorityClass.High;
C#设置线程优先级的方法
Thread.CurrentThread.Priority = ThreadPriority.Highest;
Python 设置 进程 优先级
下面的方法可以设置windows进程的优先级,默认情况会设置当前进程的优先级,你可以通过传进程id参数来设定任何一个存在进程的优先级。
def setpriority(pid=None,priority=2):
""" Set The Priority of a Windows Process. Priority is a value between 0-5 where
2 is normal priority. Default sets the priority of the current
python process but can take any valid process ID. """
import win32api,win32process,win32con
priorityclasses = [win32process.IDLE_PRIORITY_CLASS,
win32process.BELOW_NORMAL_PRIORITY_CLASS,
win32process.NORMAL_PRIORITY_CLASS,
win32process.ABOVE_NORMAL_PRIORITY_CLASS,
win32process.HIGH_PRIORITY_CLASS,
win32process.REALTIME_PRIORITY_CLASS]
if pid == None:
pid = win32api.GetCurrentProcessId()
handle = win32api.OpenProcess(win32con.PROCESS_ALL_ACCESS, True, pid)
win32process.SetPriorityClass(handle, priorityclasses[priority])
本文详细介绍了如何使用C#和Python设置进程和线程的优先级,包括C#中使用Process和Thread类的方法,以及Python中通过win32api和win32process模块设置Windows进程优先级的技巧。
3006

被折叠的 条评论
为什么被折叠?



