J
joe
Hi,
My program communicates with the serial port and shows
some information on the screen. The communication class
creates a separate thread for reading from the port. If a
character is received, an event is fired from the thread.
public event CharacterReceived;
private void ReceiveThread()
{
...
if (CharacterReceived!=null)
{
CharacterReceived(...)// notify subscribers
}
}
The subscribers of this event are controls (forms and user
controls). Because the handlers are called on
ReceiveThread, all the UI function in the handlers must be
called with BeginInvoke. Cant I, instead of tracing all
these functions and making them thread-safe, just fire
CharacterReceived on the UI thread somehow
Thanks
My program communicates with the serial port and shows
some information on the screen. The communication class
creates a separate thread for reading from the port. If a
character is received, an event is fired from the thread.
public event CharacterReceived;
private void ReceiveThread()
{
...
if (CharacterReceived!=null)
{
CharacterReceived(...)// notify subscribers
}
}
The subscribers of this event are controls (forms and user
controls). Because the handlers are called on
ReceiveThread, all the UI function in the handlers must be
called with BeginInvoke. Cant I, instead of tracing all
these functions and making them thread-safe, just fire
CharacterReceived on the UI thread somehow
Thanks