Share via


AsyncBuilder.For<'T> Method (F#)

Implements the for expression in asynchronous computations. Creates an asynchronous computation that enumerates the sequence on demand and runs a function representing the body of a for expression for each element.

Namespace/Module Path: Microsoft.FSharp.Control

Assembly: FSharp.Core (in FSharp.Core.dll)

// Signature:
member this.For : seq<'T> * ('T -> Async<unit>) -> Async<unit>

// Usage:
asyncBuilder.For (sequence, body)

Parameters

  • sequence
    Type: seq<'T>

    The sequence to enumerate.

  • body
    Type: '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.

Return Value

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

Remarks

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.

Platforms

Windows 8, Windows 7, Windows Server 2012, Windows Server 2008 R2

Version Information

F# Core Library Versions

Supported in: 2.0, 4.0, Portable

See Also

Reference

Control.AsyncBuilder Class (F#)

Microsoft.FSharp.Control Namespace (F#)