Environment.ProcessorCount Environment.ProcessorCount Environment.ProcessorCount Environment.ProcessorCount Property

Definition

Gets the number of processors on the current machine.

public:
 static property int ProcessorCount { int get(); };
public static int ProcessorCount { get; }
member this.ProcessorCount : int
Public Shared ReadOnly Property ProcessorCount As Integer
Property Value

The 32-bit signed integer that specifies the number of processors on the current machine. There is no default. If the current machine contains multiple processor groups, this property returns the number of logical processors that are available for use by the common language runtime (CLR).

Examples

The following example demonstrates the ProcessorCount property.

// This example demonstrates the 
//     Environment.ProcessorCount property.
using namespace System;
int main()
{
   Console::WriteLine( "The number of processors on this computer is {0}.", Environment::ProcessorCount );
}

/*
This example produces the following results:

The number of processors on this computer is 1.
*/
// This example demonstrates the 
//     Environment.ProcessorCount property.
using System;

class Sample 
{
    public static void Main() 
    {
    Console.WriteLine("The number of processors " +
        "on this computer is {0}.", 
        Environment.ProcessorCount);
    }
}
/*
This example produces the following results:

The number of processors on this computer is 1.
*/
' This example demonstrates the 
'     Environment.ProcessorCount property.
Imports System

Class Sample
   Public Shared Sub Main()
      Console.WriteLine("The number of processors " & _
                        "on this computer is {0}.", _
                        Environment.ProcessorCount)
   End Sub 'Main
End Class 'Sample
'
'This example produces the following results:
'
'The number of processors on this computer is 1.
'

Remarks

For more information about processor groups and logical processors, see Processor Groups.

Applies to