I suggest we ...

Async.WaitTask for non generic Task

Async.WaitTask has an overload for Task<'T> but has no support for Task.
Adding a Task -> Async<unit> overload would make things easier when dealing with C# and BCL async methods.

9 votes
Sign in
Sign in with: facebook google
Signed in as (Sign out)
You have left! (?) (thinking…)
thinkb4coding shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →


Sign in
Sign in with: facebook google
Signed in as (Sign out)
  • Veikko Eeva commented  ·   ·  Flag as inappropriate

    I'm not sure if this is the right place for this, but it looks like there's on occassion a need to also convert Task<Unit> to plain Task.

    Maybe something like this

    let inline TaskUnitToTask(task: Task<Unit>) =
    task :> Task

    It may not be "easy" to discover one could do a plain upcast to transform a F# Task<Unit> to C# style Task. Which is the situation I've come across Task<Unit> types (e.g. C# function returning taking or giving plain tasks).

  • Don Syme commented  ·   ·  Flag as inappropriate

    I consider this "approved in principle" for the F# language design, to be added as soon as implementation+testing is provided, for F# 4.0 or beyond.

    I'd encourage you to contribute the implementation and testing for this one.

    There is one small problem: adding an extra overload can be considered a breaking change, e.g.

    let f x = Async.AwaitTask(x)

    will no longer compile. For this reason, it looks sensible to call the new method "AwaitTaskUntyped", "AwaitTaskNonGeneric" or the like. A good satisfying name is hard to find.

    Comments on names welcome.

F# Language

Feedback and Knowledge Base