Asynchronous F# programming sandbox.
-
orthogonal concepts:
- concurrency
- parallelism
- asynchrony - not at the same time
-
Async<T>
type represents a composable asynchronous operations -
Async
module contains functions which:- schedule
- compose
- transform
asynchronous operations.
Examples:
async { }
- computation expression/asynchronous expression. All expressions of such form are of typeAsync<T>
for someT
. sourceexpr := async { aexpr }
- complete syntax for asynchronous expressions.- selected
aexpr
examples:do!
- execute async (Async<unit>
).let!
- execute and bind async (Async<T>
).return! expr
- tailcall to asyncreturn expr
- return result of async expression
Task<T> -> Async<T>
- interop translation of C#Task<T>
to F#Async<T>
.- asynchronous function - normal function or method, but returning an asynchronous computation. It is common for asynchronous functions to have their entire bodies enclosed in
async { }
. - cancellation:
-
C#
CancellationTokenSource
andCancellationToken
are both supported. -
cancellation tokens are implicitly propagated through the execution of an asynchronous operation.
-
Cancellation tokens are provided at the entry point to the execution of an asynchronous computation, e.g.:
Async.RunSynchronously
Async.StartImmediate
Async.Start
reference: https://stackoverflow.com/questions/15284209/async-start-vs-async-startchild
-
- exceptions:
- basic exceptions
- nested exceptions
- nested cancellations.