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

Convert field to an auto-property with a private setter.

Refers to #36
parent 3a2c6969
No related branches found
No related tags found
No related merge requests found
......@@ -43,7 +43,6 @@ namespace ATxCommon.Monitoring
private readonly PerformanceCounter _cpuCounter;
private readonly float[] _loadReadings = {0F, 0F, 0F, 0F};
private float _load;
private int _interval;
private int _limit;
private int _behaving;
......@@ -54,7 +53,7 @@ namespace ATxCommon.Monitoring
/// Current CPU load (usage percentage over all cores), averaged of the last four readings.
/// </summary>
/// <returns>The average CPU load from the last four readings.</returns>
public float Load() => _load;
public float Load { get; private set; }
/// <summary>
/// How often (in ms) to check the CPU load.
......@@ -140,7 +139,7 @@ namespace ATxCommon.Monitoring
// ConstrainedCopy seems to be the most efficient approach to shift the array:
Array.ConstrainedCopy(_loadReadings, 1, _loadReadings, 0, 3);
_loadReadings[3] = _cpuCounter.NextValue();
_load = _loadReadings.Average();
Load = _loadReadings.Average();
if (_loadReadings[3] > _limit) {
if (_behaving > _probation) {
// this means the load was considered as "low" before, so raise an event:
......
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