Catch all exceptions from Exit shutdown (master). (#12522)
This commit is contained in:
parent
34903da1e9
commit
69feac2633
|
|
@ -62,19 +62,21 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
|
|
||||||
private void Shutdown()
|
private 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();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue