diff --git a/ATxService/AutoTx.cs b/ATxService/AutoTx.cs index bb8a9cf3100d3862094688bba1ad26ac7461baaf..61d3cc4dcc996e91b5e4135005464b84ae09de96 100644 --- a/ATxService/AutoTx.cs +++ b/ATxService/AutoTx.cs @@ -44,9 +44,6 @@ namespace ATxService private long _txCurFileSize; private int _txCurFileProgress; private int _waitCyclesBeforeNextTx; - public PerformanceCounter CpuCounter; - private float _cpuLoad; - private readonly float[] _cpuLoadLastReadings = {0F, 0F, 0F, 0F}; private Cpu _cpu; private DateTime _lastUserDirCheck = DateTime.MinValue; @@ -77,7 +74,6 @@ namespace ATxService private ServiceStatus _status; private static Timer _mainTimer; - private static Timer _loadTimer; #endregion @@ -92,12 +88,6 @@ namespace ATxService SetupFileLogging(); Log.Info("=".PadLeft(80, '=')); Log.Info("Attempting to start {0} service...", ServiceName); - try { - CpuCounter = new PerformanceCounter("Processor", "% Processor Time", "_Total"); - } - catch (Exception ex) { - Log.Error("initializing PerformanceCounter failed: {0}", ex.Message); - } CreateEventLog(); LoadSettings(); CreateIncomingDirectories(); @@ -378,24 +368,6 @@ namespace ATxService #endregion - private void UpdateCpuLoad(object sender, ElapsedEventArgs elapsedEventArgs) { - _loadTimer.Enabled = false; - try { - Log.Trace("UpdateCpuLoad(), old values: {0}, average: {1}", - string.Join(", ", _cpuLoadLastReadings), _cpuLoadLastReadings.Average()); - Array.ConstrainedCopy(_cpuLoadLastReadings, 1, _cpuLoadLastReadings, 0, 3); - _cpuLoadLastReadings[3] = CpuCounter.NextValue(); - _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); - } - finally { - _loadTimer.Enabled = true; - } - } #region overrides for ServiceBase methods (start, stop, ...) @@ -408,9 +380,6 @@ namespace ATxService _mainTimer.Elapsed += OnTimedEvent; _mainTimer.Enabled = true; - _loadTimer = new Timer(250); - _loadTimer.Elapsed += UpdateCpuLoad; - _loadTimer.Enabled = true; _cpu = new Cpu(); } @@ -503,7 +472,7 @@ namespace ATxService // while this method has not finished yet: _mainTimer.Enabled = false; - Log.Debug("CPU load: {0:#} / {1:#} ({2:#.##})", _cpuLoad, _cpu.Load(), _cpuLoad - _cpu.Load()); + Log.Debug("CPU load: {0:#.##}", _cpu.Load()); try { RunMainTasks();