Skip to content

Commit

Permalink
Move await statements into catch and finally blocks
Browse files Browse the repository at this point in the history
References #1
  • Loading branch information
andreashuber-lawo committed Oct 29, 2015
1 parent 13d4741 commit 7b9eab8
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions Lawo.GlowAnalyzerProxy.Main/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,6 @@ private async Task ForwardLoop(TcpListener listener)
}

var logInfo = new LogInfo(logPath);
Exception exception;

try
{
Expand All @@ -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
{
Expand Down

0 comments on commit 7b9eab8

Please sign in to comment.