C# High CPU usage on Listener thread, sleeping misses disconnect
My connection handler is below (this is more for personal experimentation than production code) If I don't add a Thread.Sleep anywhere in the while loop, it starts sucking down CPU.. Conversely, if I do Sleep to alleviate the endless while-spam, I miss the disconnection.. The CPU goes up in direct proportion to the number of clients/threads running, so it's not the listener itself that's causing the high usage, it's the actual client thread posted below.. Anyone have any ideas on how to solve this? (I'm avoiding await-based solutions as I'm not familiar enough with async/await and the threaded