Skip to content

Instantly share code, notes, and snippets.

@mvacha
Created July 14, 2016 13:58
Show Gist options
  • Save mvacha/6e53526f2b4f0ca8e046d6b339127110 to your computer and use it in GitHub Desktop.
Save mvacha/6e53526f2b4f0ca8e046d6b339127110 to your computer and use it in GitHub Desktop.
connect
Task.Factory.StartNew(async () =>
{
try
{
var res = await connectedTCS.Task;
if (res.IsFailure)
{
DeviceEvent.AuthenticationFailure(this);
connectedEvent.Set();
return;
}
res = await userStatusTCS.Task;
if (res.IsFailure)
{
DeviceEvent.AuthenticationFailure(this);
connectedEvent.Set();
return;
}
var profileRes = await profileTCS.Task;
if (profileRes.IsFailure)
{
DeviceEvent.AuthenticationFailure(this);
connectedEvent.Set();
return;
}
else
{
connectedSuccessfully = true;
rootNode = profileRes.Value;
connectedEvent.Set();
}
}
catch(AggregateException ex) when (ex.InnerExceptions.Any(e => e is TaskCanceledException))
{
connectedEvent.Set();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment