From f0faf4e52962fb810d9c35ed55b06ac5e2e863e9 Mon Sep 17 00:00:00 2001 From: "Eric J. Smith" Date: Sun, 13 Oct 2024 19:13:08 -0500 Subject: [PATCH] Make sure job DI scope is disposed --- src/Foundatio.Extensions.Hosting/Jobs/ScheduledJobRunner.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Foundatio.Extensions.Hosting/Jobs/ScheduledJobRunner.cs b/src/Foundatio.Extensions.Hosting/Jobs/ScheduledJobRunner.cs index 29b32932..471c5691 100644 --- a/src/Foundatio.Extensions.Hosting/Jobs/ScheduledJobRunner.cs +++ b/src/Foundatio.Extensions.Hosting/Jobs/ScheduledJobRunner.cs @@ -143,7 +143,7 @@ public async Task StartAsync(CancellationToken cancellationToken = default) try { using var activity = FoundatioDiagnostics.ActivitySource.StartActivity("Job " + Options.Name, ActivityKind.Server); - var scope = _serviceProvider.CreateScope(); + await using var scope = _serviceProvider.CreateAsyncScope(); var job = Options.JobFactory(scope.ServiceProvider); var result = await job.TryRunAsync(cancellationToken).AnyContext();