forked from ddrilling/AsbCloudServer
fix PeriodicBackgroundWorker.Add()
This commit is contained in:
parent
6045333f53
commit
b67c30a2c7
@ -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>
|
||||
|
@ -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()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user