title: Using await Task.Factory.StartNew on a method will return immediately
body: <p>I'm running the following code (C#7.1 Console App), and I can't really understand why the difference in behavior. </p>
  
  <p>If I await a regular async method call, or a Task.Run - it works as expected (i.e. the app doesn't return immediately). But if I use Task.Factory.StartNew - it will return immediately without the code actually running.</p>
  
  <p>Strangely enough - if I use StartNew but inside the method remove the await, it will not return immediately...</p>
  
  <p><strong>Problem: This returns immediately:</strong></p>
  
  <pre><code>static async Task Main(string[] args)
  {
      await Task.Factory.StartNew(DisplayCurrentInfo);
  }
  
  static async Task DisplayCurrentInfo()
  {
      await WaitAndApologize();
      Console.WriteLine($"The current time is {DateTime.Now.TimeOfDay:t}");
      Thread.Sleep(3000);
  }
  </code></pre>
  
  <p>i.e. - I won't get to see anything printed out to the console, and the console will already be shut down. </p>
  
  <p><strong>No problem: this doesn’t return immediately</strong>:</p>
  
  <pre><code>static async Task Main(string[] args)
  {
      await DisplayCurrentInfo(); // or await Task.Run(DisplayCurrentInfo);
  }
  
  static async Task DisplayCurrentInfo()
  {
      await WaitAndApologize();
      Console.WriteLine($"The current time is {DateTime.Now.TimeOfDay:t}");
      Thread.Sleep(3000);
  }
  </code></pre>
  
  <p><strong>Strange: this also doesn't return immediately:</strong></p>
  
  <pre><code>static async Task Main(string[] args)
  {
      await Task.Factory.StartNew(DisplayCurrentInfo); 
  }
  
  static async Task DisplayCurrentInfo()
  {
      WaitAndApologize();
      Console.WriteLine($"The current time is {DateTime.Now.TimeOfDay:t}");
      Thread.Sleep(3000);
  }
  </code></pre>
  
  <p>WaitAndApologize:</p>
  
  <pre><code>static async Task WaitAndApologize()
  {
      // Task.Delay is a placeholder for actual work.  
      await Task.Delay(2000);
      // Task.Delay delays the following line by two seconds.  
      Console.WriteLine("\nSorry for the delay. . . .\n");
  }
  </code></pre>