From 7b9eab8d056abff6c736b2ca6a23f50b1572f12c Mon Sep 17 00:00:00 2001 From: Andreas Huber Date: Thu, 29 Oct 2015 12:32:43 +0100 Subject: [PATCH] Move await statements into catch and finally blocks References #1 --- .../MainWindowViewModel.cs | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) 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 {