System.Management.ManagementClass class1 = new ManagementClass("Win32_PerfFormattedData_PerfOS_Processor");foreach (ManagementObject ob in class1.GetInstances()){ label2.Text="Name - " + ob.GetPropertyValue("Name").ToString().Trim(); object percents = ob.GetPropertyValue("PercentProcessorTime"); if (percents != null) label1.Text = "PercentProcessorTime - " + percents;else label1.Text = "PercentProcessorTime - null";}
System.Management.ManagementClass class1 = new ManagementClass("Win32_PerfFormattedData_PerfOS_Processor");foreach (ManagementObject ob in class1.GetInstances()){ label2.Text="Name - " + ob.GetPropertyValue("Name").ToString().Trim(); object percents = ob.GetPropertyValue("PercentProcessorTime"); if (percents != null) label1.Text = "PercentProcessorTime - " + percents;else label1.Text = "PercentProcessorTime - null";}