M
Michel Racicot
In my application, I have a thread that takes 100% of the CPU (Infinite
Loop)
What is the best way to prevent that? adding in a thread.sleep??? in the
While loop?
The code is the following:
// NetListener is a TCPListener
private void ListeningLoop()
{
while (Listening)
{
if (NetListener.Pending())
{
TcpClient ConnectedClient = NetListener.AcceptTcpClient();
if (ConnectedClient.Connected)
{
CurrentServer.AddClient(ConnectedClient);
_Logger.Log("New Client - " +
ConnectedClient.Client.RemoteEndPoint.ToString());
}
}
}
}
Loop)
What is the best way to prevent that? adding in a thread.sleep??? in the
While loop?
The code is the following:
// NetListener is a TCPListener
private void ListeningLoop()
{
while (Listening)
{
if (NetListener.Pending())
{
TcpClient ConnectedClient = NetListener.AcceptTcpClient();
if (ConnectedClient.Connected)
{
CurrentServer.AddClient(ConnectedClient);
_Logger.Log("New Client - " +
ConnectedClient.Client.RemoteEndPoint.ToString());
}
}
}
}