Skip to content

Commit

Permalink
Merge pull request #321 from danielcweber/UseTryMethodsForIxToObservable
Browse files Browse the repository at this point in the history
AsyncEnumerable.ToObservable: Use Try...-methods on TaskCompletionSources to avoid unexpected exceptions when the iterator is cancelled.
  • Loading branch information
Oren Novotny committed Jan 25, 2017
2 parents 2f275e1 + f47d85e commit 072abb2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Ix.NET/Source/System.Interactive.Async/ToObservable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public void OnCompleted()

if (tcs != null)
{
tcs.SetResult(false);
tcs.TrySetResult(false);
}
}

Expand All @@ -140,7 +140,7 @@ public void OnError(Exception error)

if (tcs != null)
{
tcs.SetException(error);
tcs.TrySetException(error);
}
}

Expand All @@ -165,7 +165,7 @@ public void OnNext(T value)

if (tcs != null)
{
tcs.SetResult(true);
tcs.TrySetResult(true);
}
}
}
Expand Down

0 comments on commit 072abb2

Please sign in to comment.