diff --git a/Lawo.GlowAnalyzerProxy.Main/MainWindowViewModel.cs b/Lawo.GlowAnalyzerProxy.Main/MainWindowViewModel.cs index 86867d5d..f7813ccb 100644 --- a/Lawo.GlowAnalyzerProxy.Main/MainWindowViewModel.cs +++ b/Lawo.GlowAnalyzerProxy.Main/MainWindowViewModel.cs @@ -352,7 +352,6 @@ private async Task ForwardLoop(TcpListener listener) } var logInfo = new LogInfo(logPath); - Exception exception; try { @@ -362,30 +361,23 @@ private async Task ForwardLoop(TcpListener listener) using (this.ProviderConnection.Client = await ConnectToProvider()) { - await Task.WhenAll(this.ForwardFromConsumerAsync(logInfo), this.ForwardFromProviderAsync(logInfo)); + await Task.WhenAll( + this.ForwardFromConsumerAsync(logInfo), this.ForwardFromProviderAsync(logInfo)); } } - - exception = null; } catch (Exception ex) { - exception = ex; + await EnqueueLogOperationAsync( + logInfo, "Exception", null, null, i => i.Logger.LogException(null, ex)); } finally { this.ConsumerConnection.Client = null; this.ProviderConnection.Client = null; + await EnqueueLogOperationAsync(logInfo, null, null, null, i => { i.Dispose(); return new EventInfo(); }); listener.Start(); } - - if (exception != null) - { - await EnqueueLogOperationAsync( - logInfo, "Exception", null, null, i => i.Logger.LogException(null, exception)); - } - - await EnqueueLogOperationAsync(logInfo, null, null, null, i => { i.Dispose(); return new EventInfo(); }); } else {