title: When Asp.net terminates background threads?
body: <p>I was working on a project and there is bulk e-mail sending part of it and when user clicks on the button, he/she gets the "Thanks the e-mails have been sent" immediately as a Response and the same method is firing an async thread as well.</p>
  
  <pre><code>ThreadPool.QueueUserWorkItem(SendEMail, _message);
  </code></pre>
  
  <p>This thread is queued when user clicks on the send button but since this is default <code>Background Thread</code> I was expecting when the page response ended, this thread would be terminated but it didn't happen because the current thread which fires this Thread was also a <code>Background Thread</code> and a <code>Worker Thread</code>, so which means there is an unfinished foreground thread(s) <em>(Could be MainThread or Worker Threads)</em> still alive but I don't know when they finish because their finish time will effect my background worker threads; When the last foreground thread ends, it causes the process to be terminated, so do background threads.</p>
  
  <p>Should I be afraid of this or Asp.NET can handle it automatically and I am kinda confused because I've read a lot of things about it and now everything is mixed up.</p>
  
  <p>Could you please clarify things a little bit ? </p>
  
  <p>Thanks in advance.</p>