fix PeriodicBackgroundWorker.Add()

This commit is contained in:
ngfrolov 2024-01-22 12:55:48 +05:00
parent 6045333f53
commit b67c30a2c7
Signed by: ng.frolov
GPG Key ID: E99907A0357B29A7
2 changed files with 2 additions and 4 deletions

View File

@ -89,8 +89,7 @@ public class PeriodicBackgroundWorker : BackgroundService
where T : Work, new()
{
var work = new T();
var periodic = new WorkPeriodic(work, period);
works.Add(periodic);
Add(work, period);
}
/// <summary>

View File

@ -55,14 +55,13 @@ public class PeriodicBackgroundWorkerTest
var stopwatch = Stopwatch.StartNew();
service.Add(work, period);
var delay = periodMs / 20 + periodMs * workCount - stopwatch.ElapsedMilliseconds;
var delay = (periodMs / 20) + (periodMs * workCount) - stopwatch.ElapsedMilliseconds;
await Task.Delay(TimeSpan.FromMilliseconds(delay));
//assert
Assert.Equal(workCount, result);
}
[Fact]
public async Task Enqueue_Continues_AfterExceptions()
{