0

您如何等待 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>。有没有办法改变Taskto Task<Unit>

使用 Visual Studio 2012 和 F# 3.0...

4

0 回答 0