How to control process affinity in .NET 2.0 ? I am newbie in .Net. please help !
+2
A:
Using the Process.ProcessorAffinity property.
// this will cause the process to run only on CPU 1
Process.ProcessorAffinity = new IntPtr(1 << 0);
// this will cause the process to run only on CPU 1+2
Process.ProcessorAffinity = new IntPtr(1 << 0 | 1 << 1);
Shay Erlichmen
2010-03-22 10:08:08
@divo 10x! I fixed the code
Shay Erlichmen
2010-03-22 10:32:36
+4
A:
Please have a look at my post @http://stackoverflow.com/questions/2490711/how-to-use-hardware-threads-in-c-dot-net-code-running-on-multicore-machine/2491143#2491143
Kushal Waikar
2010-03-22 10:08:14
+2
A:
In general, you do not. Sorry if that is not what you expect, but I do a LOT of server overview here and there and rarely - really rarely - see a need for that.
If you ahve to, look at the Process class - the ProcessAffinity property. But really make sure you have to in the first place.
TomTom
2010-03-22 10:09:20
In general, you DO NOT CONTROL AFFINITY. This is only usefull in VERY special cases, and I somehow dont think they apply to you. That simple. If it IS applicable, the Process class has a (documented) ProcessAffinity property that you can use. But again, most applications dont need that. Like "never".
TomTom
2010-03-22 11:05:48