title: How do you implement an async action delegate method?
body: <h1>A little background information.</h1>
  <p>I am learning the Web API stack and I am trying to encapsulate all data in the form of a &quot;<code>Result</code>&quot; object with parameters such as <code>Success</code> and <code>ErrorCodes</code>.</p>
  <p>Different methods however, would produce different results and error codes but the result object would generally be instantiated the same way.</p>
  <p>To save some time and also to learn more about <code>async</code>/<code>await</code> capabilities in C#, I am trying to wrap all the method bodies of my web API actions in an asynchronous action delegate but got caught in a bit of a snag...</p>
  <h2><strong>Given the following classes:</strong></h2>
  <pre><code>public class Result
  {
      public bool Success { get; set; }
      public List&lt;int&gt; ErrorCodes{ get; set; }
  }
  
  public async Task&lt;Result&gt; GetResultAsync()
  {
      return await DoSomethingAsync&lt;Result&gt;(result =&gt;
      {
          // Do something here
          result.Success = true;
          
          if (SomethingIsTrue)
          {
              result.ErrorCodes.Add(404);
              result.Success = false;
          }
      }
  }
  </code></pre>
  <p>I want to write a method that performs an action on a <code>Result</code> object and return it. Normally through synchronous methods it would be</p>
  <pre><code>public T DoSomethingAsync&lt;T&gt;(Action&lt;T&gt; resultBody) where T : Result, new()
  {
      T result = new T();
      resultBody(result);
      return result;
  }
  </code></pre>
  <p>But how do I transform this method into an asynchronous method using <code>async</code>/<code>await</code>?</p>
  <p>This is what I have tried:</p>
  <pre><code>public async Task&lt;T&gt; DoSomethingAsync&lt;T&gt;(Action&lt;T, Task&gt; resultBody) 
      where T: Result, new()
  {
      // But I don't know what do do from here.
      // What do I await?
  }
  </code></pre>