Пример #1
0
        public void Update()
        {
            Int64 phav = PerformanceInfo.GetPhysicalAvailableMemoryInMiB();

            TotalBytes = PerformanceInfo.GetTotalMemoryInMiB();
            UsedBytes  = TotalBytes - phav;

            double percentFree     = (double)((decimal)phav / (decimal)TotalBytes) * 100.0;
            double percentOccupied = 100.0 - percentFree;

            Memory = percentOccupied;
        }
Пример #2
0
        public void Update()
        {
            System.Runtime.InteropServices.ComTypes.FILETIME idleTime1, krnlTime1, userTime1;

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

            System.Threading.Thread.Sleep(100);

            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;
        }