title: Wrapping async methods
body: <p>I have a strange behaviour concerning wrapping asynchronous methods in C#.</p>
  
  <p>It is difficult to cut out the portion of my code that has this strange behaviour, so instead I made a test project to investigate the behaviour, and this is what I have found out.</p>
  
  <p>I have a test class which has an async method that is simply a wrapper of another async method: (In my original code it is a wrapper class which contains 2 objects, which it has wrapper methods for)</p>
  
  <pre><code>public class Test
  {
      public async Task Delay()
      {
          await Task.Delay(1000);
      }
  }
  </code></pre>
  
  <p>In my test program I am running the following code from an async event handler: (In my case the Loaded event, since I am using a WPF Window)</p>
  
  <pre><code>var test = new Test();
  await Task.Delay(1000);
  await test.Delay();
  Task.Delay(1000).Wait();
  test.Delay().Wait();
  </code></pre>
  
  <p>All is well until the last line, which never returns.</p>
  
  <p>Then I tried changing the test class to the following and the last line works:</p>
  
  <pre><code>public class Test
  {
      public Task Delay()
      {
          return Task.Delay(1000);
      }
  }
  </code></pre>
  
  <p>My question is why the first scenario does not work?</p>