Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › [C#] How do i detect how many CPU (cores) are present in a machine?
New Posts  All Forums:Forum Nav:

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

post #1 of 16
Thread Starter 
I'm unsure how to detect the number of cores (total) in a given machines CPU(s.) Anybody have a way?
Lee XT
(19 items)
 
Leon
(11 items)
 
 
CPUMotherboardGraphicsRAM
AMD FX-6300 Asus M5A97 SAPPHIRE Radeon HD 7850 AMD 4GB DDR3 1333MHZ 
RAMRAMRAMHard Drive
AMD 4GB DDR3 1333MHZ AMD 4GB DDR3 1333MHZ AMD 4GB DDR3 1333MHZ OCZ Revodrive 3 120GB 
Hard DriveCoolingOSMonitor
OCZ Vertex 4 256GB Xigmatec Rifle 120mm Windows 8 Pro MCE Acer H213H 21.5" 
MonitorKeyboardPowerCase
Acer H213H 21.5" Razer Arctossa Ultra 600W Limited Edition NZXT Black Steel 
MouseMouse PadAudio
Roccat Kone[+] Prometric Testing Center Renewal Gift Mouse Pad Realtek HD Audio 
CPUGraphicsRAMHard Drive
Phenom II X4 N970 2.2GHZ Radeon HD 6650m 8GB DDR3 1066MHZ Mushkin Callisto Deluxe 256GB 
Optical DriveOSMonitorPower
DVD Super Multi Windows 8 Pro Acer 15.6" 1366x768 Hipro 19v 4.74a 
MouseAudioOther
Razer Orochi Realtek HD Audio Intel Centrino 6230 Wireless-N + Bluetooth 3.0HS 
  hide details  
Reply
Lee XT
(19 items)
 
Leon
(11 items)
 
 
CPUMotherboardGraphicsRAM
AMD FX-6300 Asus M5A97 SAPPHIRE Radeon HD 7850 AMD 4GB DDR3 1333MHZ 
RAMRAMRAMHard Drive
AMD 4GB DDR3 1333MHZ AMD 4GB DDR3 1333MHZ AMD 4GB DDR3 1333MHZ OCZ Revodrive 3 120GB 
Hard DriveCoolingOSMonitor
OCZ Vertex 4 256GB Xigmatec Rifle 120mm Windows 8 Pro MCE Acer H213H 21.5" 
MonitorKeyboardPowerCase
Acer H213H 21.5" Razer Arctossa Ultra 600W Limited Edition NZXT Black Steel 
MouseMouse PadAudio
Roccat Kone[+] Prometric Testing Center Renewal Gift Mouse Pad Realtek HD Audio 
CPUGraphicsRAMHard Drive
Phenom II X4 N970 2.2GHZ Radeon HD 6650m 8GB DDR3 1066MHZ Mushkin Callisto Deluxe 256GB 
Optical DriveOSMonitorPower
DVD Super Multi Windows 8 Pro Acer 15.6" 1366x768 Hipro 19v 4.74a 
MouseAudioOther
Razer Orochi Realtek HD Audio Intel Centrino 6230 Wireless-N + Bluetooth 3.0HS 
  hide details  
Reply
post #2 of 16
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
Gabatha
(13 items)
 
  
CPUMotherboardGraphicsRAM
Q6600 GA-P35-DS4 PowerColor HD 3870 PCS 2x1gb pc-2 6400, Samsung 800mhz DDR2 
Hard DriveOptical DriveOSMonitor
80gb ide :( 18x dvd LG Vista Ultimate OEM 190CW 19' Philips lcd 
PowerCase
HX620W Corsair Antec p182 
  hide details  
Reply
Gabatha
(13 items)
 
  
CPUMotherboardGraphicsRAM
Q6600 GA-P35-DS4 PowerColor HD 3870 PCS 2x1gb pc-2 6400, Samsung 800mhz DDR2 
Hard DriveOptical DriveOSMonitor
80gb ide :( 18x dvd LG Vista Ultimate OEM 190CW 19' Philips lcd 
PowerCase
HX620W Corsair Antec p182 
  hide details  
Reply
post #3 of 16
Using C# I do not know. Check the System.Threading namespace.

EDIT: I don't see anything there.
post #4 of 16
Thread Starter 
Quote:
Originally Posted by CrAzYLiFe View Post
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.
Lee XT
(19 items)
 
Leon
(11 items)
 
 
CPUMotherboardGraphicsRAM
AMD FX-6300 Asus M5A97 SAPPHIRE Radeon HD 7850 AMD 4GB DDR3 1333MHZ 
RAMRAMRAMHard Drive
AMD 4GB DDR3 1333MHZ AMD 4GB DDR3 1333MHZ AMD 4GB DDR3 1333MHZ OCZ Revodrive 3 120GB 
Hard DriveCoolingOSMonitor
OCZ Vertex 4 256GB Xigmatec Rifle 120mm Windows 8 Pro MCE Acer H213H 21.5" 
MonitorKeyboardPowerCase
Acer H213H 21.5" Razer Arctossa Ultra 600W Limited Edition NZXT Black Steel 
MouseMouse PadAudio
Roccat Kone[+] Prometric Testing Center Renewal Gift Mouse Pad Realtek HD Audio 
CPUGraphicsRAMHard Drive
Phenom II X4 N970 2.2GHZ Radeon HD 6650m 8GB DDR3 1066MHZ Mushkin Callisto Deluxe 256GB 
Optical DriveOSMonitorPower
DVD Super Multi Windows 8 Pro Acer 15.6" 1366x768 Hipro 19v 4.74a 
MouseAudioOther
Razer Orochi Realtek HD Audio Intel Centrino 6230 Wireless-N + Bluetooth 3.0HS 
  hide details  
Reply
Lee XT
(19 items)
 
Leon
(11 items)
 
 
CPUMotherboardGraphicsRAM
AMD FX-6300 Asus M5A97 SAPPHIRE Radeon HD 7850 AMD 4GB DDR3 1333MHZ 
RAMRAMRAMHard Drive
AMD 4GB DDR3 1333MHZ AMD 4GB DDR3 1333MHZ AMD 4GB DDR3 1333MHZ OCZ Revodrive 3 120GB 
Hard DriveCoolingOSMonitor
OCZ Vertex 4 256GB Xigmatec Rifle 120mm Windows 8 Pro MCE Acer H213H 21.5" 
MonitorKeyboardPowerCase
Acer H213H 21.5" Razer Arctossa Ultra 600W Limited Edition NZXT Black Steel 
MouseMouse PadAudio
Roccat Kone[+] Prometric Testing Center Renewal Gift Mouse Pad Realtek HD Audio 
CPUGraphicsRAMHard Drive
Phenom II X4 N970 2.2GHZ Radeon HD 6650m 8GB DDR3 1066MHZ Mushkin Callisto Deluxe 256GB 
Optical DriveOSMonitorPower
DVD Super Multi Windows 8 Pro Acer 15.6" 1366x768 Hipro 19v 4.74a 
MouseAudioOther
Razer Orochi Realtek HD Audio Intel Centrino 6230 Wireless-N + Bluetooth 3.0HS 
  hide details  
Reply
post #5 of 16
Environment.ProcessorCount gives and integer that counts the amount of cores running on your machine.
post #6 of 16
Thread Starter 
Quote:
Originally Posted by stupid View Post
Environment.ProcessorCount gives and integer that counts the amount of cores running on your machine.
Perfect!
Lee XT
(19 items)
 
Leon
(11 items)
 
 
CPUMotherboardGraphicsRAM
AMD FX-6300 Asus M5A97 SAPPHIRE Radeon HD 7850 AMD 4GB DDR3 1333MHZ 
RAMRAMRAMHard Drive
AMD 4GB DDR3 1333MHZ AMD 4GB DDR3 1333MHZ AMD 4GB DDR3 1333MHZ OCZ Revodrive 3 120GB 
Hard DriveCoolingOSMonitor
OCZ Vertex 4 256GB Xigmatec Rifle 120mm Windows 8 Pro MCE Acer H213H 21.5" 
MonitorKeyboardPowerCase
Acer H213H 21.5" Razer Arctossa Ultra 600W Limited Edition NZXT Black Steel 
MouseMouse PadAudio
Roccat Kone[+] Prometric Testing Center Renewal Gift Mouse Pad Realtek HD Audio 
CPUGraphicsRAMHard Drive
Phenom II X4 N970 2.2GHZ Radeon HD 6650m 8GB DDR3 1066MHZ Mushkin Callisto Deluxe 256GB 
Optical DriveOSMonitorPower
DVD Super Multi Windows 8 Pro Acer 15.6" 1366x768 Hipro 19v 4.74a 
MouseAudioOther
Razer Orochi Realtek HD Audio Intel Centrino 6230 Wireless-N + Bluetooth 3.0HS 
  hide details  
Reply
Lee XT
(19 items)
 
Leon
(11 items)
 
 
CPUMotherboardGraphicsRAM
AMD FX-6300 Asus M5A97 SAPPHIRE Radeon HD 7850 AMD 4GB DDR3 1333MHZ 
RAMRAMRAMHard Drive
AMD 4GB DDR3 1333MHZ AMD 4GB DDR3 1333MHZ AMD 4GB DDR3 1333MHZ OCZ Revodrive 3 120GB 
Hard DriveCoolingOSMonitor
OCZ Vertex 4 256GB Xigmatec Rifle 120mm Windows 8 Pro MCE Acer H213H 21.5" 
MonitorKeyboardPowerCase
Acer H213H 21.5" Razer Arctossa Ultra 600W Limited Edition NZXT Black Steel 
MouseMouse PadAudio
Roccat Kone[+] Prometric Testing Center Renewal Gift Mouse Pad Realtek HD Audio 
CPUGraphicsRAMHard Drive
Phenom II X4 N970 2.2GHZ Radeon HD 6650m 8GB DDR3 1066MHZ Mushkin Callisto Deluxe 256GB 
Optical DriveOSMonitorPower
DVD Super Multi Windows 8 Pro Acer 15.6" 1366x768 Hipro 19v 4.74a 
MouseAudioOther
Razer Orochi Realtek HD Audio Intel Centrino 6230 Wireless-N + Bluetooth 3.0HS 
  hide details  
Reply
post #7 of 16
lol.. wow. @post 2.

nice try though
My e-peen..
(13 items)
 
  
CPUMotherboardGraphicsRAM
Q6600 G0 @ 3.6ghz *lapped* EVGA 680i A1 *all HS's lapped* (vDroop Mod) EVGA 8800GT SLi (740,1010)*lapped* GSkill 4x1GBs(800mhz 4-4-4-12)*lapped* 
Hard DriveOptical DriveOSMonitor
(2)7200.10 's 250GB Raid0 (1)WD 400GB *lapped* 2x LG SATA Super All-Write SATA Vista Ultimate x64*lapped* Samsung 226BW*lapped* 
KeyboardPowerCaseMouse
ZMERC Ultra X-Pro 750Watt*lapped* Ultra Aluminus (w/ 10x120mm fans)*lapped* Logitec G5 
Mouse Pad
WOWPAD 
  hide details  
Reply
My e-peen..
(13 items)
 
  
CPUMotherboardGraphicsRAM
Q6600 G0 @ 3.6ghz *lapped* EVGA 680i A1 *all HS's lapped* (vDroop Mod) EVGA 8800GT SLi (740,1010)*lapped* GSkill 4x1GBs(800mhz 4-4-4-12)*lapped* 
Hard DriveOptical DriveOSMonitor
(2)7200.10 's 250GB Raid0 (1)WD 400GB *lapped* 2x LG SATA Super All-Write SATA Vista Ultimate x64*lapped* Samsung 226BW*lapped* 
KeyboardPowerCaseMouse
ZMERC Ultra X-Pro 750Watt*lapped* Ultra Aluminus (w/ 10x120mm fans)*lapped* Logitec G5 
Mouse Pad
WOWPAD 
  hide details  
Reply
post #8 of 16
lol at post #2 also...

lawl....
good enough
(13 items)
 
  
CPUMotherboardGraphicsRAM
E6600 3ghz Gigabyte GA-EP45-DS3L 9800GT 2x2gb fatility DDR2 1066 
Hard DriveOSMonitorMouse
2 x 74gb raptor raid0 win7 64bit Samsung 245BW Razer 3G diamondback 
Mouse Pad
glass core pad 
  hide details  
Reply
good enough
(13 items)
 
  
CPUMotherboardGraphicsRAM
E6600 3ghz Gigabyte GA-EP45-DS3L 9800GT 2x2gb fatility DDR2 1066 
Hard DriveOSMonitorMouse
2 x 74gb raptor raid0 win7 64bit Samsung 245BW Razer 3G diamondback 
Mouse Pad
glass core pad 
  hide details  
Reply
post #9 of 16
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;
}
post #10 of 16
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.
Serene Power
(13 items)
 
  
CPUMotherboardGraphicsRAM
Dual Xeon E5620 Supermicro X8DAL-i EVGA 570HD SC 8GiB Corsair DDR3 1333 ECC-R 
Hard DriveOptical DriveOSMonitor
OCZ Agility 3 120GB SSD (+16TB NAS) LG 10x Blu-Ray Windows 7 x64 / Debian x64 Dell 2408WFP, P2411H 
PowerCase
850W CoolerMaster SilentPro M CoolerMaster Cosmos Pure 
  hide details  
Reply
Serene Power
(13 items)
 
  
CPUMotherboardGraphicsRAM
Dual Xeon E5620 Supermicro X8DAL-i EVGA 570HD SC 8GiB Corsair DDR3 1333 ECC-R 
Hard DriveOptical DriveOSMonitor
OCZ Agility 3 120GB SSD (+16TB NAS) LG 10x Blu-Ray Windows 7 x64 / Debian x64 Dell 2408WFP, P2411H 
PowerCase
850W CoolerMaster SilentPro M CoolerMaster Cosmos Pure 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Coding and Programming
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › [C#] How do i detect how many CPU (cores) are present in a machine?