title: Non-blocking Task.wait in .NET 4?
body: <p>I'm trying to wait for a Task result in .NET 4, much like you can by using the await keyword in .NET 4.5. I just can't figure out how to do it though...</p>
  
  <p>My code (to prove that I'm atleast trying):</p>
  
  <pre><code>    Private Function GetXDocumentFromWebLocationAsync(ByVal request As WebRequest) As XDocument
          Dim queryTask As Task(Of WebResponse)
          queryTask = task(Of WebResponse).Factory.FromAsync(AddressOf request.BeginGetResponse, AddressOf request.EndGetResponse, Nothing, Nothing)
          Return XDocument.Load(queryTask.Result.GetResponseStream)
      End Function
  </code></pre>
  
  <p>As you would expect, the GetResponse calls are executed on a different thread, but the function has to wait for the result before it can return. Unfortunately this blocks my main thread until the task has completed and I don't have the slightest clue on how to make it wait without blocking. I don't want to use the Async CTP either because that's just running away from the problem.</p>
  
  <p>What's the secret sauce?</p>