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
    类型:unit -> bool

    用于确定何时停止执行 computation 的函数。

  • computation
    类型:Async<unit>

    要执行的函数。 与 while 表达式的主体等效。

返回值

运行时行为与 while 循环相似的异步计算。

备注

创建一个反复运行 computation、直至 guard 计算结果为 false 的异步计算。

每当执行计算时都执行取消检查。 此方法的存在使得能够在 async { ... } 计算表达式语法中使用 while。

平台

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#)