This documentation is archived and is not being maintained.

ProcessThread.ProcessorAffinity Property

Sets the processors on which the associated thread can run.

Namespace: System.Diagnostics
Assembly: System (in system.dll)

public IntPtr ProcessorAffinity { set; }
/** @property */
public void set_ProcessorAffinity (IntPtr value)

public function set ProcessorAffinity (value : IntPtr)

Not applicable.

Property Value

An IntPtr that points to a set of bits, each of which represents a processor that the thread can run on.

Exception typeCondition


The processor affinity could not be set.


The platform is Windows 98 or Windows Millennium Edition.


The process is on a remote computer.

The processor affinity of a thread is the set of processors it has a relationship to. In other words, those it can be scheduled to run on.

ProcessorAffinity represents each processor as a bit. Bit 0 represents processor one, bit 1 represents processor two, and so on. The following table shows a subset of the possible ProcessorAffinity for a four-processor system.

Property value (in hexadecimal)

Valid processors






1 or 2




1 or 3


1, 2, or 3


1, 2, 3, or 4

You can also specify the single, preferred processor for a thread by setting the IdealProcessor property. A process thread can migrate from processor to processor, with each migration reloading the processor cache. Specifying a processor for a thread can improve performance under heavy system loads by reducing the number of times the processor cache is reloaded.

Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0