Hi Alex
Thanks for the reference. I have been trying with Invoke, and more recently
BeginInvoke, but they both have their problems.
Invoke does not return until the UI thread is free, which causes deadlock
when the UI thread is waiting for the worker thread to do something.
BeginInvoke returns immediately, but the UI is not updated until the thread
is free, which means that updates can occur out of sequence. In particular,
I send data out of the serial port and produce a trace in a window
on-screen. When replies are sent, I add them to the trace. The trace of the
received data is invoked from an event raised by the worker/comms thread.
When there are a lot of exchanges of outgoing and incoming data, the
outgoing data is added to the trace first, and then the incoming data, and
thus the correct sequence is lost.
I was looking for a way for the comms class to raise its 'DataReceived'
event on the UI thread, so that everything would be synchronised. Any ideas?
Charles