From: Roman Marusyk Date: Wed, 12 Aug 2020 06:20:53 +0000 (+0300) Subject: Remove throw OperationCanceledException in Host.StopAsync (#40426) X-Git-Tag: submit/tizen/20210909.063632~6058 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=17b096dfbce8a91e854f98beb5ac182ca69b10a2;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Remove throw OperationCanceledException in Host.StopAsync (#40426) --- diff --git a/src/libraries/Microsoft.Extensions.Hosting/src/Internal/Host.cs b/src/libraries/Microsoft.Extensions.Hosting/src/Internal/Host.cs index 1fcb8fd..d80b336 100644 --- a/src/libraries/Microsoft.Extensions.Hosting/src/Internal/Host.cs +++ b/src/libraries/Microsoft.Extensions.Hosting/src/Internal/Host.cs @@ -76,7 +76,6 @@ namespace Microsoft.Extensions.Hosting.Internal { foreach (IHostedService hostedService in _hostedServices.Reverse()) { - token.ThrowIfCancellationRequested(); try { await hostedService.StopAsync(token).ConfigureAwait(false); @@ -91,9 +90,14 @@ namespace Microsoft.Extensions.Hosting.Internal // Fire IHostApplicationLifetime.Stopped _applicationLifetime.NotifyStopped(); - token.ThrowIfCancellationRequested(); - await _hostLifetime.StopAsync(token).ConfigureAwait(false); - + try + { + await _hostLifetime.StopAsync(token).ConfigureAwait(false); + } + catch (Exception ex) + { + exceptions.Add(ex); + } if (exceptions.Count > 0) {