Hardware/CPU/CPULoad.cs
changeset 166 fa9dfbfc4145
parent 165 813d8bc3192f
child 167 b7cc9d09aefe
     1.1 --- a/Hardware/CPU/CPULoad.cs	Sun Aug 08 13:57:26 2010 +0000
     1.2 +++ b/Hardware/CPU/CPULoad.cs	Thu Aug 12 20:53:27 2010 +0000
     1.3 @@ -127,10 +127,10 @@
     1.4        if (this.idleTimes == null)
     1.5          return;
     1.6  
     1.7 -      long systemTime = DateTime.Now.Ticks;
     1.8 -      long[] idleTimes = GetIdleTimes();
     1.9 +      long localSystemTime = DateTime.Now.Ticks;
    1.10 +      long[] localIdleTimes = GetIdleTimes();
    1.11  
    1.12 -      if (systemTime - this.systemTime < 10000)
    1.13 +      if (localSystemTime - this.systemTime < 10000)
    1.14          return;
    1.15  
    1.16        float total = 0;
    1.17 @@ -139,28 +139,28 @@
    1.18          float value = 0;
    1.19          for (int j = 0; j < cpuid[i].Length; j++) {
    1.20            long index = cpuid[i][j].Thread;
    1.21 -          if (index < idleTimes.Length) {
    1.22 -            long delta = idleTimes[index] - this.idleTimes[index];
    1.23 +          if (index < localIdleTimes.Length) {
    1.24 +            long delta = localIdleTimes[index] - this.idleTimes[index];
    1.25              value += delta;
    1.26              total += delta;
    1.27              count++;
    1.28            }
    1.29          }
    1.30          value = 1.0f - value / (cpuid[i].Length * 
    1.31 -          (systemTime - this.systemTime));
    1.32 +          (localSystemTime - this.systemTime));
    1.33          value = value < 0 ? 0 : value;
    1.34          coreLoads[i] = value * 100;
    1.35        }
    1.36        if (count > 0) {
    1.37 -        total = 1.0f - total / (count * (systemTime - this.systemTime));
    1.38 +        total = 1.0f - total / (count * (localSystemTime - this.systemTime));
    1.39          total = total < 0 ? 0 : total;
    1.40        } else {
    1.41          total = 0;
    1.42        }
    1.43        this.totalLoad = total * 100;
    1.44  
    1.45 -      this.systemTime = systemTime;
    1.46 -      this.idleTimes = idleTimes;
    1.47 +      this.systemTime = localSystemTime;
    1.48 +      this.idleTimes = localIdleTimes;
    1.49      }
    1.50  
    1.51    }