title: await Task.Delay() vs. Task.Delay().Wait()
body: <p>In C# I have the following two simple examples:</p>
  
  <pre><code>[Test]
  public void TestWait()
  {
      var t = Task.Factory.StartNew(() =&gt;
      {
          Console.WriteLine("Start");
          Task.Delay(5000).Wait();
          Console.WriteLine("Done");
      });
      t.Wait();
      Console.WriteLine("All done");
  }
  
  [Test]
  public void TestAwait()
  {
      var t = Task.Factory.StartNew(async () =&gt;
      {
          Console.WriteLine("Start");
          await Task.Delay(5000);
          Console.WriteLine("Done");
      });
      t.Wait();
      Console.WriteLine("All done");
  }
  </code></pre>
  
  <p>The first example creates a task that prints "Start", waits 5 seconds prints "Done" and then ends the task. I wait for the task to finish and then print "All done". When I run the test it does as expected.</p>
  
  <p>The second test should have the same behavior, except that the waiting inside the Task should be non-blocking due to the use of async and await. But this test just prints "Start" and then immediately "All done" and "Done" is never printed.</p>
  
  <p>I do not know why I get this behavior :S Any help would be appreciated very much :)</p>