private void Listen() { while (!ShouldStop) { byte[] data = new byte[2048]; try { if (IsConnected) { _socket.Receive(data); } else { break; //We're not connected anymore, shut down socket. } } catch (Exception exc) { Debug.WriteLine("Socket connection to UR10 lost: " + exc.Message); break; } _analyzer.ReadURData(data); } }