Comparison between different Async types
Computation Expression1 |
Library2 |
TFM3 |
Hot/Cold4 |
Multiple Awaits 5 |
Multi-start6 |
Tailcalls7 |
CancellationToken propagation8 |
Cancellation checks9 |
Parallel when using and!10 |
use IAsyncDisposable 11 |
---|---|---|---|---|---|---|---|---|---|---|
F# Async |
FSharp.Core |
netstandard2.0 |
Cold |
Multiple |
multiple |
tailcalls |
implicit |
implicit |
No |
No |
F# AsyncEx |
IcedTasks |
netstandard2.0 |
Cold |
Multiple |
multiple |
tailcalls |
implicit |
implicit |
No |
Yes |
F# ParallelAsync |
IcedTasks |
netstandard2.0 |
Cold |
Multiple |
multiple |
tailcalls |
implicit |
implicit |
Yes |
No |
F# Task/C# Task |
FSharp.Core |
netstandard2.0 |
Hot |
Multiple |
once-start |
no tailcalls |
explicit |
explicit |
No |
Yes |
F# ValueTask |
IcedTasks |
netstandard2.0 |
Hot |
Once |
once-start |
no tailcalls |
explicit |
explicit |
Yes |
Yes |
F# ColdTask |
IcedTasks |
netstandard2.0 |
Cold |
Multiple |
multiple |
no tailcalls |
explicit |
explicit |
Yes |
Yes |
F# CancellableTask |
IcedTasks |
netstandard2.0 |
Cold |
Multiple |
multiple |
no tailcalls |
implicit |
implicit |
Yes |
Yes |
F# CancellableValueTask |
IcedTasks |
netstandard2.0 |
Cold |
Once |
multiple |
no tailcalls |
implicit |
implicit |
Yes |
Yes |
- 1 - Computation Expression
- 2 - Which Nuget package do they come from
- 3 - Which Target Framework Moniker these are available in
- 4 - Hot refers to the asynchronous code block already been started and will eventually produce a value. Cold refers to the asynchronous code block that is not started and must be started explicitly by caller code. See F# Async Tutorial and Asynchronous C# and F# (II.): How do they differ? for more info.
- 5 - ValueTask Awaiting patterns
- 6 - Multi-start refers to being able to start the asynchronous code block again. See FAQ on Task Start for more info.
- 7 - Allows use of
let rec
with the computation expression. See Tail call Recursion for more info. - 8 -
CancellationToken
is propagated to all types the support implicitCancellatationToken
passing. CallingcancellableTask { ... }
nested insideasync { ... }
(or any of those combinations) will use theCancellationToken
from when the code was started. - 9 - Cancellation will be checked before binds and runs.
- 10 - Allows parallel execution of the asynchronous code using the Applicative Syntax in computation expressions.
- 11 - Allows
use
ofIAsyncDisposable
with the computation expression. See IAsyncDisposable for more info.