From 7bb8ce55ff425f9ee46c0fd2025c32eedb270c1d Mon Sep 17 00:00:00 2001 From: Justin Kotalik Date: Mon, 2 Mar 2020 22:50:37 -0800 Subject: [PATCH] Fix exception thrown when tye run is shutting down and event pipe tries to restart. --- .../DiagnosticsCollector.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/micronetes/Micronetes.Hosting.Diagnostics/DiagnosticsCollector.cs b/src/micronetes/Micronetes.Hosting.Diagnostics/DiagnosticsCollector.cs index be335d34..6f9cf7fc 100644 --- a/src/micronetes/Micronetes.Hosting.Diagnostics/DiagnosticsCollector.cs +++ b/src/micronetes/Micronetes.Hosting.Diagnostics/DiagnosticsCollector.cs @@ -197,6 +197,11 @@ namespace Micronetes.Hosting.Diagnostics { break; } + // If the process has already exited, a ServerNotAvailableException will be thrown. + catch (ServerNotAvailableException) + { + break; + } catch (Exception ex) { if (!cancellationToken.IsCancellationRequested) @@ -230,6 +235,10 @@ namespace Micronetes.Hosting.Diagnostics catch (PlatformNotSupportedException) { } + // If the process has already exited, a ServerNotAvailableException will be thrown. + catch (ServerNotAvailableException) + { + } } using var _ = cancellationToken.Register(() => StopSession());