{
foreach (IHostedService hostedService in _hostedServices.Reverse())
{
- token.ThrowIfCancellationRequested();
try
{
await hostedService.StopAsync(token).ConfigureAwait(false);
// 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)
{