更新时间:2021-09-24 09:22:11
在F#中,异步性是由 async
计算生成器表示的,它并不完全是 Task
的类似物,但通常可以代替以下形式使用:
In F#, asynchrony is represented by the async
computation builder, which is not an exact analog of Task
, but can generally be used in place of one:
member public this.GetFooAsync (content : byte[]) =
async {
use stream = new MemoryStream(content)
return! this.bar.GetFooAsync(stream) |> Async.AwaitTask
}
|> Async.StartAsTask