Skip to content

Instantly share code, notes, and snippets.

@mvacha
Created September 18, 2016 22:03
Show Gist options
  • Select an option

  • Save mvacha/8cb333bfd9554bd051aa94748e18d93f to your computer and use it in GitHub Desktop.

Select an option

Save mvacha/8cb333bfd9554bd051aa94748e18d93f to your computer and use it in GitHub Desktop.
try
{
var res = await _connectedTCS.Task;
if (res.Result)
{
var res2 = await _userStatusTCS.Task;
if (res2.Result)
{
var res3 = await _profileTCS.Task;
if (res3.Result)
{
//success
Log.Info("Connecting to the Gateway successful");
connectedSuccessfully = true;
RootNode = _profileTCS.Task.Result.Value;
}
else
{
Log.Error("Error when connecting to the Gateway " + res3.Error);
connectedEvent.Set();
}
}
else
{
Log.Error("Error when connecting to the Gateway " + res2.Error);
connectedEvent.Set();
}
}
else
{
Log.Error("Error when connecting to the Gateway " + res1.Error);
connectedEvent.Set();
}
}
catch (AggregateException ex) when (ex.InnerExceptions.Any(e => e is TaskCanceledException))
{
Log.Error("Error when connecting to the Gateway " + "Task cancelled");
connectedEvent.Set();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment