title: Explicitly use a Func<Task> for asynchronous lambda function when Action overload is available
body: <p>Reading over <a href="http://tomasp.net/blog/csharp-async-gotchas.aspx/">this</a> blog post on some of the gotchas of C#5's async/await. It mentions in Gotcha #4 something that is quite profound and that I hadn't thought of before.</p>
  
  <p>Briefly, it covers the scenario where you have a method that has two overloads, one that takes an <code>Action</code> and one that takes a <code>Func&lt;Task&gt;</code> (for example <code>Task.Run</code>). This issue is rooted in the argument that <code>async void</code> methods should only be used for event handlers, with the post then going on to portray the following scenario - What does the compiler infer when a lambda function like the following can be compiled to both a <code>Func&lt;Task&gt;</code> and an <code>Action</code>:</p>
  
  <pre><code>Task.Run(async () =&gt; {
    await Task.Delay(1000);
  });
  </code></pre>
  
  <p>Because <code>Task.Run</code> has signatures of both <code>Task.Run(Func&lt;Task&gt;)</code> and <code>Task.Run(Action)</code>, what type is the async anonymous function compiled to? An <code>async void</code> or a <code>Func&lt;Task&gt;</code>? My gut feeling says it will compile down to an <code>async void</code> purely because its a non-generic type however the C# Compiler might be smart and give <code>Func&lt;Task&gt;</code> types preference.</p>
  
  <p>Also, is there a way to explicitly declare which overload I wish to use? I know I could just create a new instance of <code>Func&lt;Task&gt;</code> and pass in the async lambda function there but it would still compile down to a <code>async void</code> and then pass that into the constructor of the <code>Func&lt;Task&gt;</code>. What is the ideal way to make sure its compiled as a <code>Func&lt;Task&gt;</code>?</p>