title: HostingEnvironment.QueueBackgroundWorkItem - Clarification?
body: <p>I've read <a href="https://blog.stephencleary.com/2014/06/fire-and-forget-on-asp-net.html" rel="nofollow noreferrer"><em>Stephen's article</em></a> about fire and forget background actions in Asp.net.</p>
  <p>It is not recommended to use <code>Task.Run</code> for fire-and-forget because Asp.net doesn't know that you've queued a task.</p>
  <p>So if a recycle is about to occur, the task has no way of knowing it.<br />
  That's where <code>HostingEnvironment.QueueBackgroundWorkItem</code> gets in.</p>
  <p>It will know that a recycle is about to happen and will invoke the Cancellation Token.</p>
  <p>But!</p>
  <p>FWIK - Background tasks are being &quot;terminated&quot; once the main thread has finished.</p>
  <p>That means that if a request gets in (a new thread is being created/fetched) and it invokes<code>Task.Run</code>  , and the response has finished (but Task has not) then the Task will be terminated.</p>
  <p><strong>Question:</strong></p>
  <p>Does <code>QueueBackgroundWorkItem</code> solve this problem ? or does it only exist to warn about recycle?
  In other words, if there's a request which runs <code>QueueBackgroundWorkItem</code> and the response has finished, will the <code>QueueBackgroundWorkItem</code> continue to execute its code?</p>
  <p>The docs say: &quot; independent of any request&quot;, but I'm not sure if it answers my question though</p>