views:

241

answers:

4

I am curious as to what the .NET property Environment.ProcessorCount actually returns. Does it return the number of cores, the number of processors or both? If my computer had 2 processors, each with 4 cores, would Environment.ProcessorCount return 2, 4, or 8?

+3  A: 

It returns the number of logic processors, so 8 in your example.

CesarGon
A: 

If my computer had 2 processors, each with 4 cores, would Environment.ProcessorCount return 2, 4, or 8?

It returns 8, in my case anyways. (Core i7 860 cpu).

leppie
+4  A: 

It will return the NUMBER_OF_PROCESSORS environment variable. (see MSDN)

This will equal the number of logical cores - i.e. if you have a HT enabled single core processor, it will return 2.

In your case, it should return 8.

It will be the same number as the number of CPU utilization graphs you will see in task manager.

Marek
+2  A: 

The accepted answer to this SO question has all the correct, detailed information.

Alex Martelli