如何以空闲优先级启动.NET进程? [英] How do I start a .NET process with idle priority?

查看:84
本文介绍了如何以空闲优先级启动.NET进程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用System.Diagnostics.ProcessStartInfo设置用于从.NET程序启动进程的参数。该过程开始后,我可以使用

I'm using System.Diagnostics.ProcessStartInfo to set up the parameters for launching a process from a .NET program. Once the the process is started, I can use

myProcess.PriorityClass = ProcessPriorityClass.Idle

将进程的优先级更改为空闲,以便它仅在后台运行,而不会占用我的CPU能力。是否可以使用ProcessStartInfo对象指定进程应以空闲优先级启动,以便在执行过程中,进程始终不以高于空闲速度的速度运行?

To change the priority for the process to idle, so that it only runs in the background, and doesn't hog my CPU power. Is there any way using the ProcessStartInfo object to specify that the process should start with an "Idle" priority, so that at no time during execution is the process running at higher than idle speed?

推荐答案

暂停该进程,然后更改优先级,然后继续该进程。您可以使用 CreateProcess Win32函数来执行此操作 CREATE_SUSPENDED 标志,但不幸的是,我不确定是否存在.NET支持此功能,您可能需要诉诸 P /调用

Start the process suspended, then change the priority, and then resume the process. You do this with the CreateProcess Win32 function using the CREATE_SUSPENDED flag but unfortunately I am not sure if there's support in .NET for this and you might need to resort to P/Invoke.

这篇关于如何以空闲优先级启动.NET进程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆