Exemple #1
0
        public void Update()
        {
            System.Runtime.InteropServices.ComTypes.FILETIME idleTime1, krnlTime1, userTime1;

            PerformanceInfo.GetSystemTimes(out idleTime1, out krnlTime1, out userTime1);

            System.Threading.Thread.Sleep(50);

            System.Runtime.InteropServices.ComTypes.FILETIME idleTime2, krnlTime2, userTime2;
            PerformanceInfo.GetSystemTimes(out idleTime2, out krnlTime2, out userTime2);

            long idleTime = ToLong(idleTime2) - ToLong(idleTime1);
            long krnlTime = ToLong(krnlTime2) - ToLong(krnlTime1);
            long userTime = ToLong(userTime2) - ToLong(userTime1);
            long total    = krnlTime + userTime;

            CPU = (double)(total - idleTime) / total * 100.0;
        }
Exemple #2
0
 public static Int64 GetPhysicalMemory()
 {
     return(PerformanceInfo.GetTotalMemoryInMiB());
 }
Exemple #3
0
 public static Int64 GetAvailablePhysicalMemory()
 {
     return(PerformanceInfo.GetPhysicalAvailableMemoryInMiB());
 }
Exemple #4
0
 public static void GetNumProcessesAndThreads(out int numProcess, out int numThreads)
 {
     PerformanceInfo.GetNumProcessAndThreads(out numProcess, out numThreads);
 }