title: best practice for using async await in webapi
body: <p>I have .NET core Web API which as service layer. Service layer has all EF code.</p>
  
  <p>If have basecontroller with this code</p>
  
  <pre><code>protected Task&lt;IActionResult&gt; NewTask(Func&lt;IActionResult&gt; callback)
  {
      return Task.Factory.StartNew(() =&gt;
      {
          try
          {
              return callback();
          }
          catch (Exception ex)
          {
              Logger.LogError(ex.ToString());
              throw;
          }
      });
  }
  </code></pre>
  
  <p>In controller action I wrap all calls to service in above method e.g. : </p>
  
  <pre><code>[HttpGet("something")]
  public async Task&lt;IActionResult&gt; GetSomething(int somethingId)
  {
      return await NewTask(() =&gt;
      {
          var result = _somethingService.GetSomething(somethingId);
  
          if (result != null)
              return Ok(result);
          else
              return NotFound("Role not found");
      });
  }
  </code></pre>
  
  <p>Is this correct pattern considering tomorrow I may have more than one service calls in action or making calls to other webservice. Please advise.</p>