Skip to content
Snippets Groups Projects
Commit 16815f4a authored by Niko Ehrenfeuchter's avatar Niko Ehrenfeuchter :keyboard:
Browse files

Example for using the new ATxCommon.Monitoring.Cpu class.

parent 4ca08524
No related branches found
No related tags found
No related merge requests found
......@@ -8,6 +8,7 @@ using System.IO;
using System.Reflection;
using System.Timers;
using ATxCommon;
using ATxCommon.Monitoring;
using ATxCommon.NLog;
using ATxCommon.Serializables;
using NLog;
......@@ -46,6 +47,7 @@ namespace ATxService
public PerformanceCounter CpuCounter;
private float _cpuLoad;
private readonly float[] _cpuLoadLastReadings = {0F, 0F, 0F, 0F};
private Cpu _cpu;
private DateTime _lastUserDirCheck = DateTime.MinValue;
......@@ -409,6 +411,8 @@ namespace ATxService
_loadTimer = new Timer(250);
_loadTimer.Elapsed += UpdateCpuLoad;
_loadTimer.Enabled = true;
_cpu = new Cpu();
}
catch (Exception ex) {
Log.Error("Error in OnStart(): {0}", ex.Message);
......@@ -499,7 +503,7 @@ namespace ATxService
// while this method has not finished yet:
_mainTimer.Enabled = false;
Log.Debug("Current CPU load: {0}", _cpuLoad);
Log.Debug("CPU load: {0:#} / {1:#} ({2:#.##})", _cpuLoad, _cpu.Load(), _cpuLoad - _cpu.Load());
try {
RunMainTasks();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment