title: Understanding Async and await in .Net
body: <p>From the below examples I cannot understand why the <code>async</code> and <code>await</code> are not working in 1st example but working in 2nd example.</p>
  <p><strong>1st Example:</strong></p>
  <pre><code>public static async Task Main(string[] args)
  {
      Stopwatch stopWatch = new Stopwatch();
      stopWatch.Start();
  
      Console.WriteLine(&quot;started&quot;);
      var i =  await GetIntAsync(10);
      var j = await  GetstringAsync(&quot;abc&quot;);
      Console.WriteLine($&quot;int {i}, string {j}&quot;);
  
      stopWatch.Stop();
      Console.WriteLine(&quot;RunTime &quot; + stopWatch.ElapsedMilliseconds);
  }
  </code></pre>
  <p><strong>2nd Example:</strong></p>
  <pre><code>public static async Task Main(string[] args)
  {
      Stopwatch stopWatch = new Stopwatch();
      stopWatch.Start();
  
      Console.WriteLine(&quot;started&quot;);
      var i =   GetIntAsync(10);
      var j =   GetstringAsync(&quot;abc&quot;);
      await i; await j;
      Console.WriteLine($&quot;int {i.Result}, string {j.Result}&quot;);
  
      stopWatch.Stop();
      Console.WriteLine(&quot;RunTime &quot; + stopWatch.ElapsedMilliseconds);
  }
  </code></pre>
  <p><strong><code>GetIntAsync</code> method:</strong></p>
  <pre><code>public static async Task&lt;int&gt; GetIntAsync(int i)
  {
      Console.WriteLine(&quot;in get int waiting 3 sec's&quot;);
      await Task.Run(() =&gt;
      {
          Thread.Sleep(3000);
          Console.WriteLine(&quot;int wait complete&quot;);
      });
      return i;
  }
  </code></pre>
  <p><strong><code>GetstringAsync</code> Method</strong>:</p>
  <pre><code>public static async Task&lt;string&gt; GetstringAsync(string i)
  {
      Console.WriteLine(&quot;in get int waiting 6 sec's&quot;);
      await Task.Run(() =&gt;
      {
          Thread.Sleep(6000);
          Console.WriteLine(&quot;string wait complete&quot;);
      });
      return i;
  }
  </code></pre>