Недопустимая межпоточная операция (как получить доступ к элементам WinForm из событий других модулей?)C#

Место общения программистов C#
Anonymous
Недопустимая межпоточная операция (как получить доступ к элементам WinForm из событий других модулей?)

Сообщение Anonymous »


I have a module with an event for serial port signal

serialPort.DataReceived.AddHandler(SerialDataReceivedEventHandler(DataReceived)); where DataReceived is

let DataReceived a b = rxstring 5) { int myval = BitConverter.ToInt32(m, 3); textBox1.Text += " val: " + myval.ToString() + " "; but when it's trying to access textBox1 I'm getting:

Cross-thread operation not valid: Control 'textBox1' accessed from a thread other than the thread it was created on.

So the question is, How to access WinForm elements from another modules events?


Источник: https://stackoverflow.com/questions/128 ... another-mo

Вернуться в «C#»