"Posting" to GUI Thread from Background Thread

  • Thread starter Thread starter C# Learner
  • Start date Start date
C

C# Learner

I'm working on an app which uses a background thread to read data from
a socket.

At the moment I'm doing something a bit "naughty" -- I'm firing an
event after reading from the socket, and this event gets picked up by
an event handler in the GUI thread, without "synchronizing" with this
GUI thread.

How can I "synchronize" threads in .NET?
 
C# Learner said:
I'm working on an app which uses a background thread to read data from
a socket.

At the moment I'm doing something a bit "naughty" -- I'm firing an
event after reading from the socket, and this event gets picked up by
an event handler in the GUI thread, without "synchronizing" with this
GUI thread.

How can I "synchronize" threads in .NET?

Use Control.Invoke to run a delegate in the GUI thread associated with
a specific control.
 
Back
Top