Skip to content

Commit

Permalink
Use stopping token
Browse files Browse the repository at this point in the history
  • Loading branch information
ejsmith committed Oct 29, 2024
1 parent fef5425 commit 86f19c9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Foundatio.Extensions.Hosting/Jobs/ScheduledJobService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken)
}

// delay until right after next minute starts to sync with cron schedules
await Task.Delay(TimeSpan.FromSeconds(60 - _timeProvider.GetUtcNow().UtcDateTime.Second));
await Task.Delay(TimeSpan.FromSeconds(60 - _timeProvider.GetUtcNow().UtcDateTime.Second), stoppingToken);

while (!stoppingToken.IsCancellationRequested)
{
var jobsToRun = new List<ScheduledJobRunner>();
using (var activity = FoundatioDiagnostics.ActivitySource.StartActivity("Job Scheduler"))
using (FoundatioDiagnostics.ActivitySource.StartActivity("Job Scheduler"))
{
foreach (var job in _jobManager.Jobs)
if (await job.ShouldRunAsync())
Expand Down

0 comments on commit 86f19c9

Please sign in to comment.