title: Async / await on windows form application
body: <p>I'm trying to learn and implement async / await keywords on my application. I'm using an API to get data then showing them on my forms. When I try to call methods from an console application there is no problem. But if I call my async methods from Form_Shown event also there no exception but methods not working.</p>
  
  <p>So I'm calling my RefreshOrLoadDataToCache() method on Form_Shown event.</p>
  
  <pre><code>private async void LogTimeReport_Shown(object sender, EventArgs e)
  {
      // Some syncronous operations
  
      RefreshOrLoadDataToCache(); // Async methods in it 
  
      // Some syncronous operations
  }
  </code></pre>
  
  <p>In my this method created a task and wait for it. </p>
  
  <pre><code>private async void RefreshOrLoadDataToCache()
  {
      if (IsNeededToCallAPI())
      {
          var taskForTimeEntries = LoadTimeEntriesTemp();
          Task.WhenAll(taskForTimeEntries);
  
          DataTable dtTimeEntriesTemp = taskForTimeEntries.Result;
          DataTable dtEventsTemp = LoadEventsTemp();
  
          dtTimeEntriesTemp.Merge(dtEventsTemp);
      }
      else
          BindGridViews();
  }
  </code></pre>
  
  <p>This my async method. </p>
  
  <pre><code> private async Task&lt;DataTable&gt; LoadTimeEntriesTemp()
   { 
       TimeEntryHandler timeHandler = new TimeEntryHandler();
  
       TimeEntryResponse response = await timeHandler.GetTimeEntries();
  
       DataTable dt = DatatableHelper.ToDataTable&lt;TimeEntry&gt;(response.TimeEntries);
  
       foreach (DataRow drow in dt.Rows)
       {
          // Some operations on DataTable
       }
       return dt;
   }
  </code></pre>
  
  <p>In this method I'm connecting to API and getting results. I think my problem is about this method. Because when I call this method from console application it returns data. But from form application it waits for a long time but there is no result or exception.</p>
  
  <pre><code>private async Task&lt;TimeEntryResponse&gt; GetTimeEntries()
  {
      using (var client = new AuthorizedHttpClient(_client))
      {
          var data = await client.GetAsync&lt;TimeEntryResponse&gt;(parameters);
  
          if (data.StatusCode == HttpStatusCode.OK)
          {
              var response = (TimeEntryResponse)data.ContentObj;
              response.Pages = int.Parse(data.Headers.GetValues("X-Pages").First());
              response.Page = int.Parse(data.Headers.GetValues("X-Page").First());
              response.TotalRecords = int.Parse(data.Headers.GetValues("X-Records").First());
              return response;
          }
          return new TimeEntryResponse() { TimeEntries = null, STATUS = "ERROR" };
      }
  }
  </code></pre>
  
  <p>I thought that there is something I'm missing about asyncronous calls on windows forms. How can I fix my code ?</p>