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 =
7373 if ct.IsCancellationRequested then
7474 ValueOrCancelled.Cancelled( OperationCanceledException ct)
7575 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
7781
7882 let fold f acc seq =
7983 Cancellable( fun ct ->
@@ -101,14 +105,10 @@ module Cancellable =
101105 let! ct = Async.CancellationToken
102106
103107 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)
112112 }
113113
114114 let token () = Cancellable( ValueOrCancelled.Value)
You can’t perform that action at this time.
0 commit comments