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());