static Performance() { //cpu 使用率 Performance.CpuCounter = new PerformanceCounter("Processor Information", "% Processor Time", "_Total"); //cpu 信息 Performance.Win32_Processor = new ManagementClass("Win32_Processor"); ManagementObjectCollection instances = Performance.Win32_Processor.GetInstances(); ManagementObject o = null; foreach (ManagementObject i in instances) { o = i; } if (o.IsNotNull()) { Performance.NumberOfCores = Convert.ToInt32(o["NumberOfCores"]); Performance.NumberOfLogicalProcessors = Convert.ToInt32(o["NumberOfLogicalProcessors"]); } //可用内存 Performance.MemoryCounter = new PerformanceCounter("Memory", "Available MBytes"); }