I have an ASP.Net app, in which a background task runs using HostingEnvironment.QueueBackgroundWorkItem as in code below.

Question: Will the background task scheduled in code below, use a thread from the ASP.Net thread pool thread, or will it use a thread from a separate thread pool?

public ActionResult SendCustMails()
{
      HostingEnvironment.QueueBackgroundWorkItem(ct => SendCustMailsTo(ct, "Customer Notification"));
      return View();
}

private void SendCustMailsTo (CancellationToken ct, string msg)
{
      //some code is omitted
      foreach (var customer in Customers)
      {
            if (ct.IsCancellationRequested)
            {
                  break;
            }

            SendMail(customer, msg);
      }

      return ct;
}

Related posts

Recent Viewed