You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/IcedTasks/AsyncEx.fs
+19-91Lines changed: 19 additions & 91 deletions
Original file line number
Diff line number
Diff line change
@@ -25,35 +25,27 @@ type AsyncEx =
25
25
/// This is based on <see href="https://stackoverflow.com/a/66815960">How to use awaitable inside async?</see> and <see href="https://github.com/fsharp/fslang-suggestions/issues/840">Async.Await overload (esp. AwaitTask without throwing AggregateException)</see>
26
26
/// </remarks>
27
27
static member inlineAwaitAwaiter(awaiter:'Awaiter)=
28
+
let inlinehandleFinished(onNext:'a ->unit,onError:exn ->unit,awaiter)=
29
+
try
30
+
onNext (Awaiter.GetResult awaiter)
31
+
with
32
+
|:? AggregateException as ae when ae.InnerExceptions.Count =1->
33
+
onError ae.InnerExceptions.[0]
34
+
| e ->
35
+
// Why not handle TaskCanceledException/OperationCanceledException?
36
+
// From https://github.com/dotnet/fsharp/blob/89e641108e8773e8d5731437a2b944510de52567/src/FSharp.Core/async.fs#L1228-L1231:
37
+
// A cancelled task calls the exception continuation with TaskCanceledException, since it may not represent cancellation of
38
+
// the overall async (they may be governed by different cancellation tokens, or
39
+
// the task may not have a cancellation token at all).
/// This is based on <see href="https://github.com/fsharp/fslang-suggestions/issues/840">Async.Await overload (esp. AwaitTask without throwing AggregateException)</see>
/// Return an asynchronous computation that will wait for the given Task to complete and return
@@ -122,39 +82,7 @@ type AsyncEx =
122
82
/// This is based on <see href="https://github.com/fsharp/fslang-suggestions/issues/840">Async.Await overload (esp. AwaitTask without throwing AggregateException)</see>
0 commit comments