How do you await nongeneric Tasks in F# async
workflows?
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 complains that the type Task
is not compatible with type Task<'a>
. Is there a way to transform the Task
to Task<Unit>
?
Using Visual Studio 2012 & F# 3.0...