Beispiel #1
0
        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);
        }
Beispiel #2
0
        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;
        }
Beispiel #3
0
 public static extern void GetSystemInfo(ref  CPUInfo cpuinfo);
Beispiel #4
0
 public static extern void GetSystemInfo(ref CPUInfo cpuinfo);