title: Always Running Threads on Windows Service
body: <p>I'm writing a Windows Service that will kick off multiple worker threads that will listen to Amazon SQS queues and process messages. There will be about 20 threads listening to 10 queues.</p>
  
  <p>The threads will have to be always running and that's why I'm leaning towards to actually using actual threads for the worker loops rather than threadpool threads.</p>
  
  <p>Here is a top level implementation. Windows service will kick off multiple worker threads and each will listen to it's queue and process messages.</p>
  
  <pre><code>protected override void OnStart(string[] args)
  {
       for (int i = 0; i &lt; _workers; i++)
     {
        new Thread(RunWorker).Start();
     }
  }
  </code></pre>
  
  <p>Here is the implementation of the work</p>
  
  <pre><code>public async void RunWorker()
  {
    while(true)
    {
      // .. get message from amazon sqs sync.. about 20ms
      var message = sqsClient.ReceiveMessage();
  
      try
      {
         await PerformWebRequestAsync(message);
         await InsertIntoDbAsync(message);
      }
      catch(SomeExeception)
      {
         // ... log
         //continue to retry
         continue;
      }
      sqsClient.DeleteMessage();
    }
  }
  </code></pre>
  
  <p>I know I can perform the same operation with Task.Run and execute it on the threadpool thread rather than starting individual thread, but I don't see a reason for that since each thread will always be running.</p>
  
  <p>Do you see any problems with this implementation? How reliable would it be to leave threads always running in this fashion and what can I do to make sure that each thread is always running? </p>