EDN Admin
Well-known member
<font color="#008000" size=2>I have created a Windows Forms application using the C# 2008 compiler. I dragged the "SerialPort tool" onto my form so that I could get and send serial communications on the RS-232 port. This works, but when I try to update a textbox on the form with the serial port data I get a "Cross-thread operation not valid: Control TextBox accessed from a thread other than the thread it was created on." The line TextBox.Text = Buffer; below generates the exception. How can I fix this problem?
private void SerialPort_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
{
Buffer = SerialPort.ReadExisting();
TextBox.Text =Buffer;
}
Thanks in advance for any advice.
Chuck </font>
View the full article
private void SerialPort_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
{
Buffer = SerialPort.ReadExisting();
TextBox.Text =Buffer;
}
Thanks in advance for any advice.
Chuck </font>
View the full article