title: Async and Await in C#
body: <p>So I am trying to get my head wrapped around the <code>async</code> and <code>await</code> in C#, I have read a bunch, seen a few questions here on SO, but I am just not quite sure yet.</p>
  
  <p>So I have written a little sample in hopes you can help me to understand a little clearer what is happening and when to use it. Hopefully my sample is correct.</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Net.Http;
  using System.Text;
  using System.Threading.Tasks;
  
  namespace ConsoleApplication1
  {
  class Program
  {
      static void Main(string[] args)
      {
          var c = new MyClass();
          c.AccessTheWeb("http://www.google.com");
  
          Console.WriteLine("Waiting");
          Console.Read();
      }
  }
  
  public class MyClass
  {
      public async Task AccessTheWeb(string url)
      {
          var result = await GetUrl(url);
  
          Console.Write(result);
      }
  
      public async Task&lt;string&gt; GetUrl(string url)
      {
          string result;
  
          using (var client = new HttpClient())
          {
              result = await client.GetStringAsync(url);
          }
  
          return "Did async task";
      }
  }
  }
  </code></pre>