Browse Source

update

master
wanggang 1 year ago
parent
commit
a8d7584522
  1. 19
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/JobHostdService.cs

19
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 now = DateTime.UtcNow;
var nextUtc = expression.GetNextOccurrence(now); var nextUtc = expression.GetNextOccurrence(now);
var span = nextUtc - now; var span = nextUtc - now;
if (span != null) if (span != null && (int)span.Value.TotalMilliseconds > 0)
{ {
//var delay = span.Value.TotalMilliseconds; var delay = (int)span.Value.TotalMilliseconds;
//while (delay > 0) while (delay > 0)
//{ {
// var currentDelay = delay > int.MaxValue ? int.MaxValue : (int)delay; var currentDelay = delay > int.MaxValue ? int.MaxValue : delay;
// await Task.Delay(currentDelay).ConfigureAwait(false); delay -= currentDelay;
// delay -= currentDelay; await Task.Delay(currentDelay).ConfigureAwait(false);
//} }
await Task.Delay(span.Value).ConfigureAwait(false);
Debug.WriteLine($"{job.Name} 定时任务开始执行"); Debug.WriteLine($"{job.Name} 定时任务开始执行");
using var scope = this._serviceProvider.CreateScope(); using var scope = this._serviceProvider.CreateScope();
if (scope.ServiceProvider.GetService(serviceType) is IJobService jobService) if (scope.ServiceProvider.GetService(serviceType) is IJobService jobService)

Loading…
Cancel
Save