public CPUInfo GetCPUInfo() { CPUInfo CpuInfo; if (!CacheUtil.TryGetValue <CPUInfo>(cacheKey, out CpuInfo)) { CpuInfo = new CPUInfo(); GetSystemInfo(ref CpuInfo); ManagementObjectSearcher mos = new ManagementObjectSearcher("SELECT * FROM Win32_Processor"); foreach (ManagementObject mo in mos.Get()) { CpuInfo.cpuType = mo["name"].ToString(); break; } CacheUtil.Set <CPUInfo>(cacheKey, CpuInfo, CacheTime.NotRemovable); } PerformanceCounter pc = new PerformanceCounter(CategoryName, CounterName, InstanceName); CpuInfo.cpuLoad = pc.NextValue(); return(CpuInfo); }
public CPUInfo GetCPUInfo() { CPUInfo CpuInfo; if (!CacheUtil.TryGetValue<CPUInfo>(cacheKey, out CpuInfo)) { CpuInfo = new CPUInfo(); GetSystemInfo(ref CpuInfo); ManagementObjectSearcher mos = new ManagementObjectSearcher("SELECT * FROM Win32_Processor"); foreach (ManagementObject mo in mos.Get()) { CpuInfo.cpuType = mo["name"].ToString(); break; } CacheUtil.Set<CPUInfo>(cacheKey, CpuInfo, CacheTime.NotRemovable); } PerformanceCounter pc = new PerformanceCounter(CategoryName, CounterName, InstanceName); CpuInfo.cpuLoad = pc.NextValue(); return CpuInfo; }
public static extern void GetSystemInfo(ref CPUInfo cpuinfo);