Pouknouki

Await Error

Dec 26th, 2013
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 0.63 KB | None | 0 0
  1.     Sub test()
  2.         Dim HttpClient2 As HttpClient = New HttpClient()
  3.         Dim request = New HttpRequestMessage(HttpMethod.[Post], "http://www.google.com/")
  4.         Dim response = Await HttpClient.SendAsync(request) '!!!!Error on Await!!!!
  5.         Dim result = response.Content.ReadAsStringAsync().Result
  6.     End Sub
  7.  
  8.     Async Function AccessTheWebAsync() As Task(Of Integer)
  9.         Dim client As HttpClient = New HttpClient()
  10.         Dim getStringTask As Task(Of String) = client.GetStringAsync("http://google.com")
  11.         Dim urlContents As String = Await getStringTask
  12.         Return urlContents.Length
  13.     End Function
Advertisement
Add Comment
Please, Sign In to add comment