我们有一个ServicedComponent (COM+服务器应用程序),它占用大量的CPU资源。它是从Windows服务调用的,完成它所需的时间并不是很重要。
但是,我确实需要它以较低的优先级运行。如何更改它的优先级?
发布于 2011-04-07 01:07:14
我假设您的组件在服务器应用程序中运行(在您的windows服务的进程外)。
如果是这种情况,您可以在类构造函数中将COM+进程的优先级设置为BelowNormal:
public class Class1 : ServicedComponent
{
public Class1()
{
System.Diagnostics.Process process =
System.Diagnostics.Process.GetCurrentProcess();
if (process.PriorityClass !=
System.Diagnostics.ProcessPriorityClass.BelowNormal)
{
process.PriorityClass =
System.Diagnostics.ProcessPriorityClass.BelowNormal;
}
}
}如果我运行一个简单的测试,dllhost.exe进程优先级被设置为BelowNormal。
发布于 2011-03-22 21:55:51
我认为您必须将windows服务优先级设置为低。
因此,请查看以下链接。希望这能有所帮助。
http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/0799ff95-3596-40e0-9fd1-c79b4ffab731/
https://stackoverflow.com/questions/5392176
复制相似问题