After some research I was able to do what I wanted. This code takes a process, changes the priority to the lowest, and leaves affinity only to the third core of the CPU
Process[] services = Process.GetProcessesByName("WindowsBusinessService");
try
{
//change priority
services[0].PriorityClass = ProcessPriorityClass.Idle;
//change affinity
services[0].ProcessorAffinity = (IntPtr)0x0008;
}
catch (Exception)
{
Console.WriteLine("ERROR CHANGING PROCESS");
}
A list of codes for switching cores:
0x1 - 0001 - Core0
0x2 - 0010 - Core1
0x3 - 0011 - Core1 & Core0
0x4 - 0100 - Core2
0x5 - 0101 - Core2 & Core0
0x6 - 0110 - Core2 & Core1
0x7 - 0111 - Core2 & Core1 & Core0
0x8 - 1000 - Core3
0x9 - 1001 - Core3 & Core0
0xA - 1010 - Core3 & Core1
0xB - 1011 - Core3 & Core1 & Core0
0xC - 1100 - Core3 & Core2
0xD - 1101 - Core3 & Core2 & Core0
0xE - 1110 - Core3 & Core2 & Core1
0xF - 1111 - Core3 & Core2 & Core1 & Core0
you may also choose the windows command line: https://superuser.com/questions/620724/changing-windows-process-priority-via-command-line
– Rovann Linhalis
see: https://stackoverflow.com/a/4219923/4713574 and https://msdn.microsoft.com/en-us/library/system.diagnostics.processthread.processoraffinity.aspx?f=255&MSPPError=-2147217396
– Rovann Linhalis