您如何等待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
与类型Task<'a>
不兼容。有没有办法将Task
转换为Task<Unit>
?
使用Visual Studio 2012&amp; F#3.0 ......