# [C#] How do i detect how many CPU (cores) are present in a machine?



## CrAzYLiFe

Well many programs will tell you such as<

Coretemp
Everest
CPUz

But for a quick way to check,
Press
Crt + alt + del and then go to performance tab, if you see 1 cpu usage graphs then u Have 1 core, if U have a quad core u see 4, or a duo core you see 2


----------



## Cait Sith Cat

Using C# I do not know. Check the System.Threading namespace.

EDIT: I don't see anything there.


----------



## Licht

Quote:


Originally Posted by *CrAzYLiFe* 
Well many programs will tell you such as<

Coretemp
Everest
CPUz

But for a quick way to check,
Press
Crt + alt + del and then go to performance tab, if you see 1 cpu usage graphs then u Have 1 core, if U have a quad core u see 4, or a duo core you see 2

...









This is a programming question buddy. As in how to do it in code. Thats what the [C#] tag in front of the topic name was for. (And i am not getting offensive in any of this post i just thought it was funny and i'm a curious person.) Why did you think i posted it in the programming forums?

Quote:

Using C# I do not know. Check the System.Threading namespace.

EDIT: I don't see anything there.
Ditto.


----------



## stupid

*Environment.ProcessorCount* gives and integer that counts the amount of cores running on your machine.


----------



## Licht

Quote:


Originally Posted by *stupid* 
*Environment.ProcessorCount* gives and integer that counts the amount of cores running on your machine.

Perfect!


----------



## edeekeos

lol.. wow. @post 2.

nice try though


----------



## JoBlo69

lol at post #2 also...

lawl....


----------



## linskingdom

Environment.ProcessorCount is the fastest way or use the ManagementClass in the System.Management namespace to list details processor information.

using System.Management;

ManagementClass cProInfo= new ManagementClass("Win32_Processor");
foreach ( ManagementObject ob in cProInfo.GetInstances)
{
Code here;
}


----------



## ghell

I know that the question has been answered but always check the System.Environment class when looking for this kind of system information. I have seen long and complicated discussion on marshalling and native interop just to get the system username when it is already there in the Environment class, for example.


----------



## Licht

Quote:


Originally Posted by *ghell* 
I know that the question has been answered but always check the System.Environment class when looking for this kind of system information. I have seen long and complicated discussion on marshalling and native interop just to get the system username when it is already there in the Environment class, for example.

Stupid (thats his name, i'm not calling you stupid







) already beat you to it.


----------



## ghell

Which is why I said

Quote:


Originally Posted by *ghell* 
I know that the question has been answered but

at the start of my post.

My post was just general advice about looking up similar system attributes as I see questions about things like the username, hostname, processor count, os, os version etc asked frequently and they are all right there in System.Environment so if the OP ever needs to look anything else that is similar up, rather than asking on a forum straight away (as a lot of people tend to reply with poorly marshalled native calls and the like) System.Environment is a good place to look first


----------



## Unknownm

lol #2









I have to sign this OMG>


----------



## KingJacob101

C-PUZ or CoreTemp.....search them on Google.


----------



## Licht

Quote:


Originally Posted by *KingJacob101* 
C-PUZ or CoreTemp.....search them on Google.

Were you making fun of Post#2?


----------



## G|F.E.A.D|Killa

Environment.ProcessorCount is what i always used it works pretty well. when i was in school LOL. but the best way i have found is to see what CPU you have.


----------

