title: How can I know if there are any active threads?
body: <p>I have a console application that when it is running sends emails through googles smtp client. </p>
  
  <p>Code for this:</p>
  
  <pre><code>private void SendEmailThread(MailMessage message)
  {
      Thread thread = new Thread(() =&gt; _mailService.SendEmail(message));
      thread.Start();
      thread.Join();
  }
  </code></pre>
  
  <p>How do I know when all threads are completed? </p>
  
  <p>Is there a global property that is set to <code>ThreadsRunning = 0</code> when all are done?</p>
  
  <p>I would like to send a message to the console when all emails have been sent and that is done when I have no more threads. </p>
  
  <p>Something like:</p>
  
  <pre><code>if(allThreadsDone){
      Console.WriteLine("All mails are sent");
  }
  </code></pre>