Table of contents
Collapse the table of content
Expand the table of content

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

Den Delimarsky|Last Updated: 8/18/2017
1 Contributor

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)


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.


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.


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

Control.AsyncBuilder Class (F#)

Microsoft.FSharp.Control Namespace (F#)

© 2020 Microsoft