tags:

views:

119

answers:

3

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
@divo 10x! I fixed the code
Shay Erlichmen
+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
I am not getting your answer.
DotNetBeginner
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