C Interoperability between an F# asynchronous workflow and .NET Task

Despite the similarities between the asynchronous programming models exposed by C# and F# programming languages, their interoperability isn’t a trivial accomplishment. F# programs tend to use more asynchronous computation expressions than .NET Task. Both types are similar, but they do have semantic differences, as shown in chapters 7 and 8. For example, tasks start immediately after their creation, while F# Async must be explicitly started.

How can you interop between F# asynchronous computation expressions and .NET Task? It’s possible to use F# functions such as Async.StartAsTask<T> and Async.AwaitTask<T> to interop with a C# library that returns or awaits a Task type. ...

Get Concurrency in .NET now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.