title: Async Online Search freezing WPF-UI
body: <p>I'm pretty new to threading in C#. I've got a Searchfield which triggers HTTP-Request against an API on every Key pressed. After the Request the Searchresult is displayed in a ListView in my SearchTab. Of course this freezes the UI for a few milliseconds until the HTTP-Request is finished. So I tried to make the Request Async.</p>
  
  <pre><code>private async void textBoxSearch_KeyUp(object sender, KeyEventArgs e)
  {
  
      SearchTab searchTab;
  
      Task&lt;SearchContainer&lt;SearchMovie&gt;&gt; searchTask = searchMovie(textBoxSearch.Text);
  
      if (searchTabExists())
      {
          searchTab = getSearchTab();
      }
      else
      {
          searchTab = new SearchTab();
          mainTabControl.Items.Insert(mainTabControl.Items.Count, searchTab);
      }
      searchTab.IsSelected = true;
  
      SearchContainer&lt;SearchMovie&gt; results = await searchTask;
      searchTab.updateSearch(results);
  }
  
  async Task&lt;SearchContainer&lt;SearchMovie&gt;&gt; searchMovie(String query)
  {
      var today = await Task.FromResult&lt;SearchContainer&lt;SearchMovie&gt;&gt;(tmdbClient.SearchMovie(query, "de"));
      return today;
  }
  </code></pre>
  
  <p>This Code makes it a bit better but it still freezes the UI a bit, because at some point it has to wait for the API-Call. I want to be able to type my search smoothly without interruption and display the result if the API-Call is finished in time before another search is made (KeyPressed).</p>
  
  <p>How do you solve such a problem in C#? In JAVA I would use a AsyncWorker which calls the Displaymethod after the search is finished (or cancel the worker if another search is made) so that searching and displaying isn't done in the Main-Thread.</p>
  
  <p>Is there a similar construct in C#? I can only find async await solutions if I search for multithreading. Or can is use it in a way that it works like I wish.</p>