I’m trying to set the processor affinity on a process on a machine that has 16 total physical processor cores, 32 logical. Before, we were using an int but that will overflow when you have 32 logical cores.
Will using a long, instead of an int, when setting the processor affinity still work?
See the code below.
try
{
string pathToExe = GetPathToExe( jobType );
long processorAffinity = DetermineProcessorAffinity();
Process jobProcess = Process.Start( pathToExe, jobId.ToString() );
if ( jobProcess != null )
{
jobProcess.ProcessorAffinity = new IntPtr( processorAffinity );
}
}
From IntPtr documentation:
In other words: It should work on 64 bits systems, but not on 32 bit systems. I guess that’s not a problem in your case.