如何使用异步工作流等待非通用任务?

时间:2013-09-17 13:06:25

标签: asynchronous f# f#-3.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与类型Task<'a>不兼容。有没有办法将Task转换为Task<Unit>

使用Visual Studio 2012&amp; F#3.0 ......

0 个答案:

没有答案