forked from ddrilling/AsbCloudServer
Fix PeriodicBackgroundWorker
This commit is contained in:
parent
399dab884f
commit
dd99497e75
@ -17,8 +17,8 @@ public class PeriodicBackgroundWorker : BackgroundService
|
||||
private readonly TimeSpan executePeriod = TimeSpan.FromSeconds(10);
|
||||
private readonly TimeSpan minDelay = TimeSpan.FromSeconds(1);
|
||||
private readonly IServiceProvider serviceProvider;
|
||||
|
||||
private readonly List<WorkPeriodic> works = new(8);
|
||||
private bool isRuning = false;
|
||||
|
||||
/// <summary>
|
||||
/// Список периодических работ
|
||||
@ -42,6 +42,9 @@ public class PeriodicBackgroundWorker : BackgroundService
|
||||
|
||||
protected override async Task ExecuteAsync(CancellationToken token)
|
||||
{
|
||||
if (isRuning)
|
||||
return;
|
||||
isRuning = true;
|
||||
Trace.TraceInformation($"{GetType().Name} started");
|
||||
while (!token.IsCancellationRequested)
|
||||
{
|
||||
@ -74,6 +77,7 @@ public class PeriodicBackgroundWorker : BackgroundService
|
||||
Trace.TraceError(MainLoopLastException);
|
||||
}
|
||||
}
|
||||
isRuning = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
Loading…
Reference in New Issue
Block a user