Mam program, który wysyła ramkę zapytania do sterownika i po odebraniu danych chcę je wyświetlić "textBox".
private void timer1_Tick(object sender, EventArgs e)
{
port.Write(new byte[] { 0x01, 0x17, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0xB2, 0x9B }, 0, 13);
port.DataReceived += new SerialDataReceivedEventHandler(DataReceivedHandler);
}
public void DataReceivedHandler(
object sender,
SerialDataReceivedEventArgs e)
{
SerialPort sp = (SerialPort)sender;
data = sp.ReadExisting();
dane = ASCIIEncoding.ASCII.GetBytes(data);
labelTest.Text = ("Odebrano dane");
textBox1.Text = Convert.ToString(dane[1]);
}
Gdy próbuję wyświetlić odebrane dane w textBox dostaję komunikat:
"Additional information: Nieprawidłowa operacja między wątkami: do formantu 'textBox1' uzyskiwany jest dostęp z wątku innego niż wątek, w którym został utworzony."
Proszę o pomoc jak to rozwiązać.