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

Async.Ignore<'T> Method (F#)

Den Delimarsky|Last Updated: 6/9/2016
1 Contributor

Creates an asynchronous computation that runs the given computation and ignores its result.

Namespace/Module Path: Microsoft.FSharp.Control

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


// Signature:
static member Ignore : Async<'T> -> Async<unit>

// Usage:
Async.Ignore (computation)


computation Type: Async<'T>

The input computation.

Return Value

A computation that is equivalent to the input computation, but disregards the result.


The following code example illustrates the use of Async.Ignore.

    open System
    open System.IO

    let writeToFile filename numBytes = 
        async {
            use file = File.Create(filename)
            printfn "Writing to file %s." filename
            do! file.AsyncWrite(Array.zeroCreate<byte> numBytes)

    let readFile filename numBytes =
        async {
            use file = File.OpenRead(filename)
            printfn "Reading from file %s." filename
            // Throw away the data being read.
            do! file.AsyncRead(numBytes) |> Async.Ignore
    let filename = "BigFile.dat"
    let numBytes = 100000000

    writeToFile filename numBytes
    |> Async.RunSynchronously

    readFile filename numBytes
    |> Async.RunSynchronously


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.Async Class (F#)

Microsoft.FSharp.Control Namespace (F#)

© 2016 Microsoft