I want to wait for a line to be read, but only for so long before timing out. This is what I came up with. Is there a better way to do it?
Dim reader As New System.IO.StreamReader(pipe)
Dim nextCommand = Await New Func(Of Task(Of String))(
Function()
Dim t = reader.ReadLineAsync()
If (Not t.Wait(2000)) Then Throw New MyTimeoutExeption()
Return t
End Function).Invoke()