using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.IO.Ports; namespace WindowsFormsApplication1 { public partial class Form1 : Form { SerialPort mySerialPort = new SerialPort("COM6",115200); string indata; private void serialPort1_DataReceived(object sender,System.IO.Ports.SerialDataReceivedEventArgs e) { try { if (InvokeRequired) { Invoke(new MethodInvoker(writetotextbox)); } } catch { } } //write to textbox private void writetotextbox() { mySerialPort.Open(); string s; try { textBox1.AppendText(mySerialPort.ReadExisting()); } catch { return; } mySerialPort.Close(); } public Form1() { } } }