title: Is there any way to await an IAsyncResult in Windows Phone 8?
body: <p>How can I use <strong>await</strong> with HttpWebRequest in Windows Phone 8 ?</p>
  
  <p>Is there a way to make the IAsyncResult stuff work with await?</p>
  
  <pre><code>private async Task&lt;int&gt; GetCurrentTemperature()
  {
    GeoCoordinate location = GetLocation();
  
    string url = "http://free.worldweatheronline.com/feed/weather.ashx?q=";
    url += location.Latitude.ToString();
    url += ",";
    url += location.Longitude.ToString();
    url += "&amp;format=json&amp;num_of_days=1&amp;key=MYKEY";
  
    HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
    webRequest.Method = "POST";
    webRequest.BeginGetResponse(new AsyncCallback(OnGotWebRequest), webRequest);
  }
  
  private void OnGotWebRequest(IAsyncResult asyncResult)
  {
    HttpWebRequest webRequest = (HttpWebRequest)asyncResult.AsyncState;
    var httpResponse = (HttpWebResponse)webRequest.EndGetResponse(asyncResult);
    using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
    {
      string responseText = streamReader.ReadToEnd();
    }
  }
  </code></pre>
  
  <p>Thanks!</p>