In this page, the following code is an example for changing the affinity of the current process:
using System;
using System.Diagnostics;
class Program
{
static void Main()
{
Process myProcess = Process.GetCurrentProcess();
Console.WriteLine("ProcessorAffinity: {0}", myProcess.ProcessorAffinity);
Process.GetCurrentProcess().ProcessorAffinity = (System.IntPtr)3;
Console.WriteLine("ProcessorAffinity: {0} ", myProcess.ProcessorAffinity);
Console.ReadKey();
}
}
But the output for me is:
ProcessorAffinity: 255
ProcessorAffinity: 255
meaning that the affinity is not changed. What's the problem? And how can I change the affinity?