File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -38,6 +38,12 @@ module AsyncExtensions =
3838
3939#if NET40
4040
41+ /// Starts a non-generic Task with the cancellationToken and returns an
42+ /// Async<unit > containing the result.
43+ static member AwaitTask ( task : Tasks.Task , ? cancellationToken ) =
44+ let cancel = defaultArg cancellationToken Async.DefaultCancellationToken
45+ Async.AwaitTask <| task.ContinueWith(( fun t -> ()), cancel)
46+
4147 /// Starts a Task<'a> with the timeout and cancellationToken and
4248 /// returns a Async<a' option> containing the result. If the Task does
4349 /// not complete in the timeout interval, or is faulted None is returned.
@@ -54,6 +60,7 @@ module AsyncExtensions =
5460 /// 'Bind' of the 'async' builder. The new overload awaits on
5561 /// a standard .NET task
5662 type Microsoft.FSharp.Control.AsyncBuilder with
57- member x.Bind ( t : Tasks.Task < 'T >, f : 'T -> Async < 'R >) : Async < 'R > = async.Bind( Async.AwaitTask t, f)
63+ member x.Bind ( t : Tasks.Task < 'T >, f : 'T -> Async < 'R >) : Async < 'R > = async.Bind( Async.AwaitTask t, f)
64+ member x.Bind ( t : Tasks.Task , f : unit -> Async < unit >) : Async < unit > = async.Bind( Async.AwaitTask t, f)
5865
5966#endif
You can’t perform that action at this time.
0 commit comments