FSharp.Core


AsyncBuilder Type

The type of the async operator, used to build workflows for asynchronous computations.

Instance members

Instance member Description

this.Bind

Full Usage: this.Bind

Parameters:
    computation : Async<'T> - The computation to provide an unbound result.
    binder : 'T -> Async<'U> - The function to bind the result of computation.

Returns: Async<'U> An asynchronous computation that performs a monadic bind on the result of computation.
Modifiers: inline
Type parameters: 'T, 'U

Creates an asynchronous computation that runs computation, and when computation generates a result T, runs binder res.

A cancellation check is performed when the computation is executed. The existence of this method permits the use of let! in the async { ... } computation expression syntax.

computation : Async<'T>

The computation to provide an unbound result.

binder : 'T -> Async<'U>

The function to bind the result of computation.

Returns: Async<'U>

An asynchronous computation that performs a monadic bind on the result of computation.

this.Combine

Full Usage: this.Combine

Parameters:
    computation1 : Async<unit> - The first part of the sequenced computation.
    computation2 : Async<'T> - The second part of the sequenced computation.

Returns: Async<'T> An asynchronous computation that runs both of the computations sequentially.
Modifiers: inline
Type parameters: 'T

Creates an asynchronous computation that first runs computation1 and then runs computation2, returning the result of computation2.

A cancellation check is performed when the computation is executed. The existence of this method permits the use of expression sequencing in the async { ... } computation expression syntax.

computation1 : Async<unit>

The first part of the sequenced computation.

computation2 : Async<'T>

The second part of the sequenced computation.

Returns: Async<'T>

An asynchronous computation that runs both of the computations sequentially.

this.Delay

Full Usage: this.Delay

Parameters:
    generator : unit -> Async<'T> - The function to run.

Returns: Async<'T> An asynchronous computation that runs generator.

Creates an asynchronous computation that runs generator.

A cancellation check is performed when the computation is executed.

generator : unit -> Async<'T>

The function to run.

Returns: Async<'T>

An asynchronous computation that runs generator.

this.For

Full Usage: this.For

Parameters:
    sequence : seq<'T> - The sequence to enumerate.
    body : 'T -> Async<unit> - A function to take an item from the sequence and create an asynchronous computation. Can be seen as the body of the for expression.

Returns: Async<unit> An asynchronous computation that will enumerate the sequence and run body for each element.

Creates an asynchronous computation that enumerates the sequence seq on demand and runs body for each element.

A cancellation check is performed on each iteration of the loop. The existence of this method permits the use of for in the async { ... } computation expression syntax.

sequence : seq<'T>

The sequence to enumerate.

body : 'T -> Async<unit>

A function to take an item from the sequence and create an asynchronous computation. Can be seen as the body of the for expression.

Returns: Async<unit>

An asynchronous computation that will enumerate the sequence and run body for each element.

this.Return

Full Usage: this.Return

Parameters:
    value : 'T - The value to return from the computation.

Returns: Async<'T> An asynchronous computation that returns value when executed.
Modifiers: inline
Type parameters: 'T

Creates an asynchronous computation that returns the result v.

A cancellation check is performed when the computation is executed. The existence of this method permits the use of return in the async { ... } computation expression syntax.

value : 'T

The value to return from the computation.

Returns: Async<'T>

An asynchronous computation that returns value when executed.

this.ReturnFrom

Full Usage: this.ReturnFrom

Parameters:
    computation : Async<'T> - The input computation.

Returns: Async<'T> The input computation.
Modifiers: inline
Type parameters: 'T

Delegates to the input computation.

The existence of this method permits the use of return! in the async { ... } computation expression syntax.

computation : Async<'T>

The input computation.

Returns: Async<'T>

The input computation.

this.TryFinally

Full Usage: this.TryFinally

Parameters:
    computation : Async<'T> - The input computation.
    compensation : unit -> unit - The action to be run after computation completes or raises an exception (including cancellation).

Returns: Async<'T> An asynchronous computation that executes computation and compensation afterwards or when an exception is raised.
Modifiers: inline
Type parameters: 'T

Creates an asynchronous computation that runs computation. The action compensation is executed after computation completes, whether computation exits normally or by an exception. If compensation raises an exception itself the original exception is discarded and the new exception becomes the overall result of the computation.

A cancellation check is performed when the computation is executed. The existence of this method permits the use of try/finally in the async { ... } computation expression syntax.

computation : Async<'T>

The input computation.

compensation : unit -> unit

The action to be run after computation completes or raises an exception (including cancellation).

Returns: Async<'T>

An asynchronous computation that executes computation and compensation afterwards or when an exception is raised.

this.TryWith

Full Usage: this.TryWith

Parameters:
    computation : Async<'T> - The input computation.
    catchHandler : exn -> Async<'T> - The function to run when computation throws an exception.

Returns: Async<'T> An asynchronous computation that executes computation and calls catchHandler if an exception is thrown.
Modifiers: inline
Type parameters: 'T

Creates an asynchronous computation that runs computation and returns its result. If an exception happens then catchHandler(exn) is called and the resulting computation executed instead.

A cancellation check is performed when the computation is executed. The existence of this method permits the use of try/with in the async { ... } computation expression syntax.

computation : Async<'T>

The input computation.

catchHandler : exn -> Async<'T>

The function to run when computation throws an exception.

Returns: Async<'T>

An asynchronous computation that executes computation and calls catchHandler if an exception is thrown.

this.Using

Full Usage: this.Using

Parameters:
    resource : 'T - The resource to be used and disposed.
    binder : 'T -> Async<'U> - The function that takes the resource and returns an asynchronous computation.

Returns: Async<'U> An asynchronous computation that binds and eventually disposes resource.

Creates an asynchronous computation that runs binder(resource). The action resource.Dispose() is executed as this computation yields its result or if the asynchronous computation exits by an exception or by cancellation.

A cancellation check is performed when the computation is executed. The existence of this method permits the use of use and use! in the async { ... } computation expression syntax.

resource : 'T

The resource to be used and disposed.

binder : 'T -> Async<'U>

The function that takes the resource and returns an asynchronous computation.

Returns: Async<'U>

An asynchronous computation that binds and eventually disposes resource.

this.While

Full Usage: this.While

Parameters:
    guard : unit -> bool - The function to determine when to stop executing computation.
    computation : Async<unit> - The function to be executed. Equivalent to the body of a while expression.

Returns: Async<unit> An asynchronous computation that behaves similarly to a while loop when run.

Creates an asynchronous computation that runs computation repeatedly until guard() becomes false.

A cancellation check is performed whenever the computation is executed. The existence of this method permits the use of while in the async { ... } computation expression syntax.

guard : unit -> bool

The function to determine when to stop executing computation.

computation : Async<unit>

The function to be executed. Equivalent to the body of a while expression.

Returns: Async<unit>

An asynchronous computation that behaves similarly to a while loop when run.

this.Zero

Full Usage: this.Zero

Returns: Async<unit> An asynchronous computation that returns ().

Creates an asynchronous computation that just returns ().

A cancellation check is performed when the computation is executed. The existence of this method permits the use of empty else branches in the async { ... } computation expression syntax.

Returns: Async<unit>

An asynchronous computation that returns ().