Alternative to a bunch of while (true) loops when awaiting messages or client connections? (TcpClient C#)
<p>I thought C# was an event-driven programming language.</p>

<p>This type of thing seems rather messy and inefficient to me:</p>

<pre><code>tcpListener.Start();

while (true)
{
    TcpClient client = this.tcpListener.AcceptTcpClient();

    Thread clientThread = new Thread(new ParameterizedThreadStart(HandleClientCommunication));

    clientThread.Start(client);
}
</code></pre>

<p>I also have to do the same kind of thing when waiting for new messages to arrive. Obviously these functions are enclosed within a thread.</p>

<p>Is there not a better way to do this that doesn't involve infinite loops and wasted CPU cycles? Events? Notifications? Something? If not, is it bad practice to do a Thread.Sleep so it isn't processing as nearly as often?</p>
