title: Why will an empty .NET Task not complete if started and waited for from a static constructor?
body: <p>I cannot understand why the following code will not work:</p>
  
  <pre><code>var task = new Task(() =&gt; { });
  task.Start();
  if (task.Wait(10000))
  {
     logger.Info("Works");
  }
  else
  {  
     logger.Info("Doesn't work");
  }
  </code></pre>
  
  <p>The task status is stuck on "Running" after the timeout expires, although there is nothing to be done. Replacing <code>task.Start()</code> with <code>task.RunSynchronously()</code> will work however.</p>
  
  <p>Does anyone have an idea of what I may be doing wrong? </p>
  
  <p>A test project to replicate the issue is available here: <a href="http://erwinmayer.com/dl/TaskTestProject.zip" rel="nofollow">http://erwinmayer.com/dl/TaskTestProject.zip</a>. As far as I can see, it doesn't work if the method with the above code runs within the static constructor. But it works if called directly as a static class method.</p>
  
  <p>This recent MSDN blog post seems to highlight related issues with static constructors: <a href="http://blogs.msdn.com/b/pfxteam/archive/2011/05/03/10159682.aspx" rel="nofollow">http://blogs.msdn.com/b/pfxteam/archive/2011/05/03/10159682.aspx</a></p>