The System.Management namespace provides access to a wide range of management information and management event collections related to system, device, and application setting checkpoints based on the Windows Management Instrumentation (WMI) architecture. Applications and services can use classes derived from ManagementObjectSearcher and managementquery to query for administrative information of interest (for example, how much free space is left on the disk, what is the current CPU utilization, Which database an application is connecting to, and so on), or that applications and services can subscribe to a variety of administrative events using the ManagementEventWatcher class. These accessible data can come from managed and unmanaged components in a distributed environment. Use the ManagementClass class under the System.Management namespace to get the CPU number. First, add a reference to the System.Management class library. You can then add the following code to get the number of the CPU.
System.Management.ManagementClass mc = new ManagementClass("win32_processor");
ManagementObjectCollection moc = mc.GetInstances();
foreach (ManagementObject mo in moc)
{
MessageBox.Show(mo["processorid"].ToString());
}