private void UpdateCpu(WindowsProfileDataModel dataModel)
{
if ((_cores == null) || (_overallCpu == null))
return;
// CPU is only updated every 15 frames, the performance counter gives 0 if updated too often
_cpuFrames++;
if (_cpuFrames < 16)
return;
_cpuFrames = 0;
// Update cores, not ideal but data models don't support lists.
if (_cores[0] != null)
dataModel.Cpu.Core1Usage = (int) _cores[0].NextValue();
if (_cores[1] != null)
dataModel.Cpu.Core2Usage = (int) _cores[1].NextValue();
if (_cores[2] != null)
dataModel.Cpu.Core3Usage = (int) _cores[2].NextValue();
if (_cores[3] != null)
dataModel.Cpu.Core4Usage = (int) _cores[3].NextValue();
if (_cores[4] != null)
dataModel.Cpu.Core5Usage = (int) _cores[4].NextValue();
if (_cores[5] != null)
dataModel.Cpu.Core6Usage = (int) _cores[5].NextValue();
if (_cores[6] != null)
dataModel.Cpu.Core7Usage = (int) _cores[6].NextValue();
if (_cores[7] != null)
dataModel.Cpu.Core8Usage = (int) _cores[7].NextValue();
//From Ted - Let's get overall RAM and CPU usage here
dataModel.Cpu.TotalUsage = (int) _overallCpu.NextValue();
var phav = PerformanceInfo.GetPhysicalAvailableMemoryInMiB();
var tot = PerformanceInfo.GetTotalMemoryInMiB();
var percentFree = phav/(decimal) tot*100;
var percentOccupied = 100 - percentFree;
dataModel.Performance.RAMUsage = (int) percentOccupied;
}