public void ReadLoop() { IPEndPoint anyAddr = new IPEndPoint(IPAddress.IPv6Any, 0); while (running) { bool activity = false; if (udpc.Poll(10000, SelectMode.SelectRead)) { EndPoint recvAddr = anyAddr; int bytesRead = udpc.ReceiveFrom(readBuffer, 0, readBuffer.Length, SocketFlags.None, ref recvAddr); if (bytesRead > 0) { activity = true; IPEndPoint recvIPAddr = recvAddr as IPEndPoint; networkHandler.HandleUDPMessage(readBuffer, bytesRead, recvIPAddr); } } if (!activity) { Thread.Sleep(5); } } }