title: Calling async method on button click
body: <p>I created Windows Phone 8.1 project and I am trying to run <code>async</code> method <code>GetResponse&lt;T&gt;(string url)</code> on button click and waiting for the method to finish, but method is never finishing. Here is my code:</p>
  <pre><code>private void Button_Click(object sender, RoutedEventArgs 
  {
        Task&lt;List&lt;MyObject&gt;&gt; task = GetResponse&lt;MyObject&gt;(&quot;my url&quot;);
        task.Wait();
        var items = task.Result; //break point here
  }
  
  public static async Task&lt;List&lt;T&gt;&gt; GetResponse&lt;T&gt;(string url)
  {
      List&lt;T&gt; items = null;
      HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
  
      var response = (HttpWebResponse)await Task.Factory.FromAsync&lt;WebResponse&gt;(request.BeginGetResponse, request.EndGetResponse, null);
      try
      {
          Stream stream = response.GetResponseStream();
          StreamReader strReader = new StreamReader(stream);
          string text = strReader.ReadToEnd();
          items = JsonConvert.DeserializeObject&lt;List&lt;T&gt;&gt;(text);
      }
      catch (WebException)
      {
          throw;
      }
      return items;
  }
  </code></pre>
  <p>It will hang on <code>task.Wait()</code>.</p>
  <p>I changed my button click method to <code>async</code> and used <code>await</code> before the <code>async</code> method and I get the result(<code>await GetResponse&lt;string&gt;(&quot;url&quot;)</code>). What is wrong with <code>Task&lt;List&lt;string&gt;&gt; task = GetResponse&lt;string&gt;(&quot;url&quot;)</code>?
  What am I doing wrong?</p>
  <p>Thanks for the help!</p>