title: Should I use an async wrapper when calling the Hangfire BackgroundJob.Enqueue method?
body: <p>Is it a good idea to put the Enqueue method in an async wrapper and have the controller call it that way? </p>
  
  <p>Which is better and why?</p>
  
  <p><strong>Synchronously:</strong></p>
  
  <pre><code>    public IActionResult AddLogs(List&lt;Log&gt; logs)
      {
          BackgroundJob.Enqueue(() =&gt; DM.AddLogsBackground(logs));
          return Ok();
      }
  </code></pre>
  
  <p><strong>Async:</strong></p>
  
  <pre><code>    public async Task&lt;IActionResult&gt; AddLogs(List&lt;Log&gt; logs)
      {
          await DM.AddLogs(logs);
          return Ok();
      }
  
      public async Task AddLogs(List&lt;Log&gt; logs)
      {
          BackgroundJob.Enqueue(() =&gt; AddLogsBackground(logs));
      }
  </code></pre>
  
  <p>The <a href="http://docs.hangfire.io/en/latest/background-methods/calling-methods-in-background.html" rel="nofollow noreferrer">documentation</a> says:</p>
  
  <blockquote>
    <p>The Enqueue method does not call the target method immediately, it
    runs the following steps instead:</p>
    
    <ol>
    <li>Serialize a method information and all its arguments.</li>
    <li>Create a new background job based on the serialized information.</li>
    <li>Save background job to a persistent storage.</li>
    <li>Enqueue background job to its queue.</li>
    </ol>
  </blockquote>