Delay one second inside LockAsync

This commit is contained in:
aden.chen 2025-10-15 14:38:42 +08:00
parent b8636a7c40
commit 79c6bf7fd3

View file

@ -31,14 +31,11 @@ public class CrontabWatcher : BackgroundService
while (!stoppingToken.IsCancellationRequested) while (!stoppingToken.IsCancellationRequested)
{ {
var delay = Task.Delay(1000, stoppingToken);
await locker.LockAsync(DIST_KEY, async () => await locker.LockAsync(DIST_KEY, async () =>
{ {
await RunCronChecker(scope.ServiceProvider); await RunCronChecker(scope.ServiceProvider);
await Task.Delay(1000, stoppingToken);
}); });
await delay;
} }
_logger.LogWarning("Crontab Watcher background service is stopped."); _logger.LogWarning("Crontab Watcher background service is stopped.");