System. the Management namespace provides access to a large number of Management information and Management event sets, which are consistent with Windows Management specifications (WMI) structure is related to Setting Detection Points for systems, devices, and applications. Applications and Services can use classes derived from ManagementObjectSearcher and ManagementQuery, query the management information you are interested in (for example, the amount of available space on the disk, the current CPU usage, and the database to which an application is connected ); or applications and services can use the ManagementEventWatcher class to book various management events. These accessible data can come from hosted and unmanaged components in a distributed environment. You can use the ManagementClass class in the System. Management namespace to obtain the CPU number. First, add a reference to the System. Management class library. Then add the following code to obtain 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 ());
}