title: best practice for using an infinite while loop to process client/server data
body: <p>I'm working on a client - server application. And I have an infinite while loop to check if the client (or server) has sent data. </p>
  
  <pre><code>while (true)
  {
      // do things
  }
  </code></pre>
  
  <p>But what is the best practice with this? With the above code, when the server accepts an client, the CPU of the system jumps to 100%. </p>
  
  <p>If I put <code>Threading.Thread.Sleep(500)</code> at the end of the loop, CPU usages is better, but I wonder whether this is the best way, or whether it should be different.</p>
  
  <p>(I am able to get the data asynchronously, I know--but my question isn't that, it's about the best practice for the while loop, so that the application does not completely consume the CPU)</p>