public void ReadPort() { while (true) { try { if (CurrentPort.IsOpen) { int count = CurrentPort.BytesToRead; if (count > 0) { byte[] ByteArray = new byte[count]; CurrentPort.Read(ByteArray, 0, count); string text = Encoding.UTF8.GetString(ByteArray); if (LogText.Length > 100) { LogText = LogText.Substring(80, 20); } LogText += text; } } } catch { } } }