共用方式為


AsyncBuilder.While 方法 (F#)

實作 while關鍵字在 非同步計算的運算式。

命名空間/模組路徑: Microsoft.FSharp.Control

組件:FSharp.Core (在 FSharp.Core.dll 中)

// Signature:
member this.While : (unit -> bool) * Async<unit> -> Async<unit>

// Usage:
asyncBuilder.While (guard, computation)

參數

  • guard
    Type: unit -> bool

    決定何時停止執行 computation 的函式。

  • computation
    型別:Async<unit>

    要執行的函式。 等於 while 運算式的主體。

傳回值

執行時的行為與 while 迴圈類似的非同步計算。

備註

建立一個非同步計算執行 computation重複直到 guard評估為 False。

只要執行計算,就會執行取消檢查。 如果這個方法存在,則允許將 while 用於 async { ... } 計算運算式語法。

平台

Windows 7、Windows Vista SP2、Windows XP SP3、Windows XP x64 SP2、Windows Server 2008 R2、Windows Server 2008 SP2、Windows Server 2003 SP2

版本資訊

F# 執行階段

支援版本:2.0、4.0

Silverlight

支援版本:3

請參閱

參考

Control.AsyncBuilder 類別 (F#)

Microsoft.FSharp.Control 命名空間 (F#)