diff --git a/AsbCloudInfrastructure/Background/PeriodicBackgroundWorker.cs b/AsbCloudInfrastructure/Background/PeriodicBackgroundWorker.cs index dedd6d83..edc3aa8e 100644 --- a/AsbCloudInfrastructure/Background/PeriodicBackgroundWorker.cs +++ b/AsbCloudInfrastructure/Background/PeriodicBackgroundWorker.cs @@ -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 works = new(8); + private bool isRuning = false; /// /// Список периодических работ @@ -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; } ///