diff --git a/src/ConsoleAppFramework/ConsoleAppEngineService.cs b/src/ConsoleAppFramework/ConsoleAppEngineService.cs index 6dcd1f3..4d373d5 100644 --- a/src/ConsoleAppFramework/ConsoleAppEngineService.cs +++ b/src/ConsoleAppFramework/ConsoleAppEngineService.cs @@ -85,7 +85,14 @@ public async Task StopAsync(CancellationToken cancellationToken) } finally { - scope.Dispose(); + if (scope is IAsyncDisposable asyncDisposable) + { + await asyncDisposable.DisposeAsync(); + } + else + { + scope.Dispose(); + } } } }