File tree Expand file tree Collapse file tree 1 file changed +9
-9
lines changed Expand file tree Collapse file tree 1 file changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -73,7 +73,11 @@ module Cancellable =
73
73
if ct.IsCancellationRequested then
74
74
ValueOrCancelled.Cancelled( OperationCanceledException ct)
75
75
else
76
- oper ct
76
+ try
77
+ oper ct
78
+ with
79
+ | :? OperationCanceledException as e when ct.IsCancellationRequested -> ValueOrCancelled.Cancelled e
80
+ | :? OperationCanceledException as e -> InvalidOperationException( " Wrong cancellation token" , e) |> raise
77
81
78
82
let fold f acc seq =
79
83
Cancellable( fun ct ->
@@ -101,14 +105,10 @@ module Cancellable =
101
105
let! ct = Async.CancellationToken
102
106
103
107
return !
104
- Async.FromContinuations( fun ( cont , econt , ccont ) ->
105
- try
106
- match run ct c with
107
- | ValueOrCancelled.Value v -> cont v
108
- | ValueOrCancelled.Cancelled ce -> ccont ce
109
- with
110
- | : ? OperationCanceledException as ce when ct .IsCancellationRequested -> ccont ce
111
- | : ? OperationCanceledException as e -> InvalidOperationException ( "Wrong cancellation token ", e ) |> econt )
108
+ Async.FromContinuations( fun ( cont , _econt , ccont ) ->
109
+ match run ct c with
110
+ | ValueOrCancelled.Value v -> cont v
111
+ | ValueOrCancelled.Cancelled ce -> ccont ce)
112
112
}
113
113
114
114
let token () = Cancellable( ValueOrCancelled.Value)
You can’t perform that action at this time.
0 commit comments