void PortBDataReceived(object sender, SerialDataReceivedEventArgs e) { Thread.Sleep(200); string bytestr = ""; bytestr = _portB.ReadExisting(); bytestr = bytestr.Replace("\r", ""); UTF8Encoding utf = new UTF8Encoding(); byte[] myarray = utf.GetBytes(bytestr); string hexvalues = ""; foreach (byte b in myarray) { hexvalues = hexvalues + (b.ToString("X2")) + " "; } UpdGuiEvent.Invoke(hexvalues); }