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

Use property from timer directly rather than shadowing it locally.

parent 18369b64
Branches
No related tags found
No related merge requests found
...@@ -21,8 +21,6 @@ namespace ATxCommon.Monitoring ...@@ -21,8 +21,6 @@ namespace ATxCommon.Monitoring
private int _limit; private int _limit;
private int _behaving; private int _behaving;
private int _probation; private int _probation;
private bool _enabled;
/// <summary> /// <summary>
/// Current CPU load (usage percentage over all cores). /// Current CPU load (usage percentage over all cores).
...@@ -69,8 +67,11 @@ namespace ATxCommon.Monitoring ...@@ -69,8 +67,11 @@ namespace ATxCommon.Monitoring
/// Indicating whether the CPU load monitoring is active. /// Indicating whether the CPU load monitoring is active.
/// </summary> /// </summary>
public bool Enabled { public bool Enabled {
get => _enabled; get => _monitoringTimer.Enabled;
set => EnableTimer(value); set {
Log.Debug("{0} CPU monitoring.", value ? "Enabling" : "Disabling");
_monitoringTimer.Enabled = value;
}
} }
...@@ -101,11 +102,6 @@ namespace ATxCommon.Monitoring ...@@ -101,11 +102,6 @@ namespace ATxCommon.Monitoring
Log.Debug("Initializing CPU monitoring completed."); Log.Debug("Initializing CPU monitoring completed.");
} }
private void EnableTimer(bool enabled) {
Log.Debug("{0} CPU monitoring.", enabled ? "Enabling" : "Disabling");
_monitoringTimer.Enabled = enabled;
_enabled = enabled;
}
private void UpdateCpuLoad(object sender, ElapsedEventArgs e) { private void UpdateCpuLoad(object sender, ElapsedEventArgs e) {
_monitoringTimer.Enabled = false; _monitoringTimer.Enabled = false;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment