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 the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.