Search code examples
.netload-balancingmulticore

The weird load balancing on a multicore process machine


I am analyzing some .net desktop application. I have found that code:

if (System.Environment.ProcessorCount > 1)
{
    Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.High;
    Process.GetCurrentProcess().ProcessorAffinity = new IntPtr(2);
}
else
{
    Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.AboveNormal;
}

Process.GetCurrentProcess().PriorityBoostEnabled = true;

I have launched this application on machine that has the multi core (4) processor: enter image description here

As we can see application loads only the second core (see code), but at the same time I cannot do anything on my computer even so 3 cores are in idle.

What is happing?? Does it make sense to run application using the particular core?

ADDED

There is other application(2) that can hold the rest processor time. It works with high priority and I cannot change it's setting. So this application should be in competition with that one.


Solution

  • Does your application have a main window? Is it in the foreground? If yes, no wonder since PriorityBoostEnabled=true will make your application's priority even higher then.