diff --git a/ATxService/AutoTx.cs b/ATxService/AutoTx.cs index 1655ef07eeee3c83358aeb6c8a48f689133534bd..fb941a8a1a9aaae1f3a3783a09513ad47f7698c5 100644 --- a/ATxService/AutoTx.cs +++ b/ATxService/AutoTx.cs @@ -379,13 +379,13 @@ namespace ATxService private void UpdateCpuLoad(object sender, ElapsedEventArgs elapsedEventArgs) { _loadTimer.Enabled = false; try { - Log.Debug("UpdateCpuLoad()"); - Log.Debug(_cpuLoadLastReadings.Average()); + Log.Trace("UpdateCpuLoad(), old values: {0}, average: {1}", + string.Join(", ", _cpuLoadLastReadings), _cpuLoadLastReadings.Average()); Array.ConstrainedCopy(_cpuLoadLastReadings, 1, _cpuLoadLastReadings, 0, 3); - // var counter = new PerformanceCounter("Processor", "% Processor Time", "_Total"); _cpuLoadLastReadings[3] = CpuCounter.NextValue(); - Log.Debug(_cpuLoadLastReadings.Average()); - Log.Debug("UpdateCpuLoad() finished"); + _cpuLoad = _cpuLoadLastReadings.Average(); + Log.Trace("UpdateCpuLoad(), new values: {0}, average: {1}", + string.Join(", ", _cpuLoadLastReadings), _cpuLoadLastReadings.Average()); } catch (Exception ex) { Log.Error("UpdateCpuLoad failed: {0}", ex.Message); @@ -406,7 +406,7 @@ namespace ATxService _mainTimer.Elapsed += OnTimedEvent; _mainTimer.Enabled = true; - _loadTimer = new Timer(1000); + _loadTimer = new Timer(250); _loadTimer.Elapsed += UpdateCpuLoad; _loadTimer.Enabled = true; } @@ -499,6 +499,8 @@ namespace ATxService // while this method has not finished yet: _mainTimer.Enabled = false; + Log.Debug("Current CPU load: {0}", _cpuLoad); + try { RunMainTasks(); GC.Collect();