title: await Task.Run(...) behaving differently for console and windows application
body: <p>I have a console application with the following code </p>
  
  <pre><code>static void Main(string[] args) {
      Method();
      Console.ReadKey();
  }
  
  private static void Method() {
      Task t = DoSomething();
      t.Wait();
      Console.WriteLine("Finished");
  }
  
  private static async Task DoSomething() {
      await Task.Run(() =&gt;
          Thread.Sleep(1000));
  }
  </code></pre>
  
  <p>Everything works exactly as I expect it to and the console displays "Finished" one second after running the program. When I move the same code into a windows application then I find that the program just stops</p>
  
  <pre><code>private void button1_Click(object sender, EventArgs e) {
      Task t = DoSomething();
      t.Wait();
      MessageBox.Show("Finished");
  }
  
  private static async Task DoSomething() {
      await Task.Run(() =&gt;
          Thread.Sleep(1000));
  }
  </code></pre>
  
  <p>The debugger shows the current line of execution is t.Wait(), even after the Task in the DoSomething method has been run. </p>
  
  <p>Is there something different that I need to do in a windows application that I don't need to do in a console application? Or am I fundamentally misunderstanding something?</p>