Snippets tagged task

  • Extending async with await on tasks

    The snippet shows how to extend the built-in F# async computation builder with the ability to await standard .NET tasks using the let! keyword.

    18 people like this

    Posted: 11 years ago by Tomas Petricek

  • Converting a Task to IObservable

    Helper Type Extension to convert a System.Threading.Tasks.Task to IObservable.

    1 people like this

    Posted: 8 years ago by Riccardo Terrell

  • Async task computation expression

    Async task computation expression, in order to avoid Async.AwaitTask for C# interop

    3 people like this

    Posted: 7 years ago by cboudereau

  • Await Computation Expression (Task + Async Interoperability)

    When writing asynchronous code in F#, one often needs to call methods in the .NET BCL that return Task or Task rather than the F# native Async<'a> type. While the Async.AwaitTask function can convert a Task into an Async<'a>, there is some cognitive overhead in having to keep track of which functions return Task and which functions are Async. To simplify this interoperability, this code provides new `await` computation expression that supports using both Async<'a> and Task or Task inside it. This works by unifying the Task and Async types in the Awaitable DU, and overloading the Bind, ReturnFrom, Combine, and Using methods on the AwaitableBuilder Computation Builder to handle Awaitable<'a>, Async<'a>, Task, and Task.

    5 people like this

    Posted: 5 years ago by Aaron Eshbach