Catch all exceptions from Exit shutdown (#12518)
This commit is contained in:
parent
9feeb664da
commit
c809b669b9
|
|
@ -135,18 +135,21 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
{
|
{
|
||||||
void Shutdown()
|
void Shutdown()
|
||||||
{
|
{
|
||||||
if (!cts.IsCancellationRequested)
|
try
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(shutdownMessage))
|
if (!cts.IsCancellationRequested)
|
||||||
{
|
|
||||||
Console.WriteLine(shutdownMessage);
|
|
||||||
}
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
|
if (!string.IsNullOrEmpty(shutdownMessage))
|
||||||
|
{
|
||||||
|
Console.WriteLine(shutdownMessage);
|
||||||
|
}
|
||||||
cts.Cancel();
|
cts.Cancel();
|
||||||
}
|
}
|
||||||
catch (ObjectDisposedException) { }
|
|
||||||
}
|
}
|
||||||
|
// When hosting with IIS in-process, we detach the Console handle on main thread exit.
|
||||||
|
// Console.WriteLine may throw here as we are logging to console on ProcessExit.
|
||||||
|
// We catch and ignore all exceptions here. Do not log to Console in thie exception handler.
|
||||||
|
catch (Exception) { }
|
||||||
|
|
||||||
// Wait on the given reset event
|
// Wait on the given reset event
|
||||||
resetEvent.Wait();
|
resetEvent.Wait();
|
||||||
|
|
@ -184,4 +187,4 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
await host.StopAsync();
|
await host.StopAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue