If the Process proc variable contains the required process ( Process.GetCurrentProcess() for the current process, get it from GetProcesses() or GetProcessesByName() , etc. for another process. Then:
foreach(ProcessThread pt in proc.Threads) { pt.IdealProcessor = 0; pt.ProcessorAffinity = (IntPtr)1; }
IdealProcessor is the null identifier of a single core. ProcessorAffinity is a bitmask, therefore 1 allows zero zero, 2 allows one core, 3 allows zero and one kernels, 4 allows two kernels, etc.
I would check this out completely . The odds are very strong that it will actually hurt your performance, reducing the ability to use different cores, which is usually an advantage.
Jon hanna
source share