Catch all exceptions from Exit shutdown (master). (#12522)

This commit is contained in:
Justin Kotalik 2019-07-24 14:56:04 -07:00 committed by GitHub
parent 34903da1e9
commit 69feac2633
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 8 deletions

View File

@ -61,6 +61,8 @@ namespace Microsoft.AspNetCore.Hosting
}
private void Shutdown()
{
try
{
if (!_cts.IsCancellationRequested)
{
@ -68,13 +70,13 @@ namespace Microsoft.AspNetCore.Hosting
{
Console.WriteLine(_shutdownMessage);
}
try
{
_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
_resetEvent.Wait();
}