2

We have a ServicedComponent (COM+ server application) which is quite CPU intensive. It's called from a Windows Service and the amount of time it takes for it to complete is not very important.

However, I do need it to run with lower priority. How can I change it's priority?

jgauffin
  • 99,844
  • 45
  • 235
  • 372

2 Answers2

1

I think you have to set the windows service priority to low.

So please look into the below link. Hope that helps.

http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/0799ff95-3596-40e0-9fd1-c79b4ffab731/

Nirmal
  • 1,223
  • 18
  • 32
  • And how do I find the correct `dllhost.exe` that hosts the COM+ application? Or do you mean that the `dllhost.exe` will get the same priority as the calling windows service? – jgauffin Mar 22 '11 at 14:02
  • @jgauffin, check this link for the dllhost.exe. http://www.jasonsamuel.com/2010/01/13/how-to-tell-which-com-application-belongs-to-what-dllhost-exe-in-iis/ – Nirmal Mar 22 '11 at 14:08
0

I'm assuming that your component is running in a Server Application (out of process from your windows service).

If that is the case you could set the priority of the COM+ process to be BelowNormal in the class constructor:

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;
        }
    }
}

If I run a simple test the dllhost.exe process priority is set to be BelowNormal.

Randy Levy
  • 22,566
  • 4
  • 68
  • 94