Async.Ignore<'T>-Methode (F#)
Erstellt eine asynchrone Berechnung, die die angegebene Berechnung ausführt und das Ergebnis ignoriert.
Namespace/Modulpfad: Microsoft.FSharp.Control
Assembly: FSharp.Core (in FSharp.Core.dll)
// Signature:
static member Ignore : Async<'T> -> Async<unit>
// Usage:
Async.Ignore (computation)
Parameter
computation
Typ: Async<'T>Die Eingabeberechnung.
Rückgabewert
Eine Berechnung, die der Eingabeberechnung entspricht, jedoch das Ergebnis ignoriert.
Beispiel
Das folgende Codebeispiel veranschaulicht die Verwendung von 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
Plattformen
Windows 7, Windows Vista SP2, Windows XP SP3, Windows XP x64 SP2, Windows Server 2008 R2, Windows Server 2008 SP2, Windows Server 2003 SP2
Versionsinformationen
F#-Runtime
Unterstützt in: 2.0, 4.0
Silverlight
Unterstützt in: 3
Siehe auch
Weitere Ressourcen
Microsoft.FSharp.Control-Namespace (F#)
Änderungsprotokoll
Datum |
Versionsgeschichte |
Grund |
---|---|---|
Juli 2010 |
Codebeispiel hinzugefügt. |
Informationsergänzung. |