title: Task.Run how to write it with action and ref variable name
body: <p>I am standing for a "little" syntax problem and cannt figure out how to correctly write what I desire.</p>
  
  <p>I have the following method:</p>
  
  <pre><code>public void DoSomeMagic(string foo, ref string bar)
  {
      //DoSomeMagic...
  }
  </code></pre>
  
  <p>Now I would like to offload this code inside a Task.Run I would normally write the following:</p>
  
  <pre><code>public async void Button_Click(object sender, EventArgs args)
  {
      string foo = "Hello Foo";
      string bar = "Hello Bar";
  
      await Task.Run(() =&gt; DoSomeMagic(foo, ref bar));
  }
  </code></pre>
  
  <p>This doesn't compile telling me: "Cannot use 'ref' or 'out' parameter 'bar' inside an anonymous method body"</p>
  
  <p>So I thought why even do the () => since I am just calling the method and I could reduce it to this:</p>
  
  <pre><code>Task.Run(DoSomeMagic(foo, ref bar));
  </code></pre>
  
  <p>This again doesn't compile telling me: Cannot resolve method 'Run(void)', candidates are: Run(Action) and Run(Func)</p>
  
  <p>So again no problem Visual Studio your demand is my command.</p>
  
  <p>And changed the code to this:</p>
  
  <pre><code>Task.Run((Action)DoSomeMagic(foo, ref bar));
  </code></pre>
  
  <p>Again doesn't compile telling me: Cannot cast expression of type 'void' to type 'Action',</p>
  
  <p>Okay this starts getting tricky...</p>
  
  <p>I than tried to instead of returning void I will just try int and cast to Func
  giving me the error: Cannot cast expression of type 'int' to type 'Func'</p>
  
  <p>Saw that one coming but I thought lets give it a try:</p>
  
  <p>So I tried the following approach:</p>
  
  <pre><code>public Action CallDoSomeMagic(string foo, ref string bar)
  {
      //DoSomeMagic...
      return new Action(() =&gt; DoSomeMagic(foo, ref bar));
  }
  
  Task.Run(CallDoSomeMagic);
  </code></pre>
  
  <p>But this again gives me the message "Cannot use 'ref' or 'out' parameter 'bar' inside an anonymous method body"</p>
  
  <p>Since my headache is increasing with every try, I thought you guys can help me out.
  Is it even possible?</p>