/// <summary> /// Creates and returns a CpuUsage instance that can be used to query the CPU time on this operating system. /// </summary> /// <returns>An instance of the CpuUsage class.</returns> /// <exception cref="NotSupportedException">This platform is not supported -or- initialization of the CPUUsage object failed.</exception> public static CpuUsage Create() { if (m_CpuUsage == null) { if (Environment.OSVersion.Platform == PlatformID.Win32NT) m_CpuUsage = new CpuUsageNt(); else if (Environment.OSVersion.Platform == PlatformID.Win32Windows) m_CpuUsage = new CpuUsage9x(); else throw new NotSupportedException(); } return m_CpuUsage; }
private void setupCPULoad() { try { cpu = CpuUsage.Create(); t = new System.Threading.Timer(new TimerCallback(TimerFunction), null, 0, 500); } catch (Exception e) { Console.WriteLine(e); } }