您如何等待 F#async
工作流中的非泛型任务?
open System.IO
let openConnection = async { ... }
let answer = async {
use! stream = openConnection
let reader = new StreamReader (stream)
let! request = reader.ReadLineAsync () |> Async.AwaitTask // works fine: Task<String>
...
let writer = new StreamWriter (stream)
do! writer.WriteLineAsync "OK" |> Async.AwaitTask // error: Task
}
Visual Studio 抱怨该类型Task
与 type 不兼容Task<'a>
。有没有办法改变Task
to Task<Unit>
?
使用 Visual Studio 2012 和 F# 3.0...