Skip to content

Commit

Permalink
proper math on intervals
Browse files Browse the repository at this point in the history
  • Loading branch information
Scooletz committed Sep 3, 2024
1 parent 8ec53e0 commit fed5a86
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,8 @@ public void StartUpdating(Action onForced)
return;
async Task RunLoop(CancellationToken ct)
{
var constantDelay = TimeSpan.FromSeconds(Math.Max(_intervalSeconds - _minIntervalSeconds, 1));
var waitTime = TimeSpan.FromSeconds(_intervalSeconds) - constantDelay;
var minDelay = TimeSpan.FromSeconds(_minIntervalSeconds);
TimeSpan waitTime = TimeSpan.FromSeconds(_intervalSeconds) - minDelay;

while (ct.IsCancellationRequested == false)
{
Expand Down Expand Up @@ -245,7 +245,7 @@ async Task RunLoop(CancellationToken ct)
// Always wait a minimal amount of time so that the metrics are not flooded
try
{
await Task.Delay(constantDelay, ct).ConfigureAwait(false);
await Task.Delay(minDelay, ct).ConfigureAwait(false);
}
catch (OperationCanceledException)
{
Expand Down

0 comments on commit fed5a86

Please sign in to comment.