Languages
[Edit]
EN

C#/.NET - get number of processors on the current machine

9 points
Created by:
Root-ssh
6442

In C#/.NET it is possible to get number of processors on the current machine with Environment.ProcessorCount property. 

Environment.ProcessorCount property example

int count = Environment.ProcessorCount;

Console.WriteLine("Number of available processors is " + count + ".");

Output:

Number of available processors is 4.

References:

  1. Environment.ProcessorCount Property - Microsoft Docs
Hey 👋
Would you like to know what we do?
  • Dirask is a friendly IT community for learners, professionals and hobbyists to share their knowledge and help each other in extraordinary easy way.
  • We welcome everyone,
    no matter what the experience,
    no matter how basic the question is,
    this community will help you.