From a8d7584522a194218d8a970dcfe3ede48762fbe0 Mon Sep 17 00:00:00 2001 From: wanggang <76527413@qq.com> Date: Sat, 29 Jul 2023 12:54:00 +0800 Subject: [PATCH] update --- .../Entities/BQ/JobHostdService.cs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/JobHostdService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/JobHostdService.cs index 1f4f34ea..69fe330a 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/JobHostdService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/JobHostdService.cs @@ -66,16 +66,15 @@ public class JobHostdService : BackgroundService, IApplicationService var now = DateTime.UtcNow; var nextUtc = expression.GetNextOccurrence(now); var span = nextUtc - now; - if (span != null) + if (span != null && (int)span.Value.TotalMilliseconds > 0) { - //var delay = span.Value.TotalMilliseconds; - //while (delay > 0) - //{ - // var currentDelay = delay > int.MaxValue ? int.MaxValue : (int)delay; - // await Task.Delay(currentDelay).ConfigureAwait(false); - // delay -= currentDelay; - //} - await Task.Delay(span.Value).ConfigureAwait(false); + var delay = (int)span.Value.TotalMilliseconds; + while (delay > 0) + { + var currentDelay = delay > int.MaxValue ? int.MaxValue : delay; + delay -= currentDelay; + await Task.Delay(currentDelay).ConfigureAwait(false); + } Debug.WriteLine($"{job.Name} 定时任务开始执行"); using var scope = this._serviceProvider.CreateScope(); if (scope.ServiceProvider.GetService(serviceType) is IJobService jobService)