title: What is the reason for "while(true) { Thread.Sleep }"?
body: <p>I sometimes encounter code in the following form:</p>
  
  <pre><code>while (true) {
    //do something
    Thread.Sleep(1000);
  }
  </code></pre>
  
  <p>I was wondering if this is considered good or bad practice and if there are any alternatives.</p>
  
  <p>Usually I "find" such code in the main-function of services.</p>
  
  <p>I recently saw code in the "Run" function in a windows azure worker role which had the following form:</p>
  
  <pre><code>ClassXYZ xyz = new ClassXYZ(); //ClassXYZ creates separate Threads which execute code
  while (true) {
    Thread.Sleep(1000);
  }
  </code></pre>
  
  <p>I assume there are better ways to prevent a service (or azure worker role) from exiting.
  Does anyone have a suggestion for me?</p>