I'm trying to raise an event from my worker thread in the SerialPort.DataReceived event in the main thread.
Background: I have a device connected that can send data by itself to the serial port of my PC. I need to recognize this data and when a telegram is completed, pass it to the UI thread to e.g. show received values. Because the data can arrive spontaneously I used the DataReceived Event of the SerialPort class.
The DataReceived Event creates its own background thread, this I know and this is my problem. When the telegram is complete, I raise an event on the open form of the application e.g. to update a certain text field. The problem is, this event raising is done in the worker thread of the SerialPort received Event.
Is there a way to raise this event on the main UI thread?