Question about Multithreading

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello everyone,
I am implementing a multithreaded tcp client with two classes,
cNetworkManager class and cUI Class, I created a secondary thread for
receiving packets using blocking "Receive" method in cNetworkManager and when
a packet is received I want to raise an event to cUI Class, but I don't want
to raise that event on my secondary thread, so does anyone know how can I
notify my main thread in cNetworkManager so the thread could raise the event
for cUI class.

Regards,
 
Jefe said:
I am implementing a multithreaded tcp client with two classes,
cNetworkManager class and cUI Class, I created a secondary thread for
receiving packets using blocking "Receive" method in cNetworkManager and when
a packet is received I want to raise an event to cUI Class, but I don't want
to raise that event on my secondary thread, so does anyone know how can I
notify my main thread in cNetworkManager so the thread could raise the event
for cUI class.

You'll need to use an ISynchronizeInvoke reference to call
Invoke/BeginInvoke/EndInvoke on. UI controls all implement this
automatically, but you'll need to pass it to the NetworkManager class
(eg in the constructor) so that it's got something to communicate with.

Jon
 
Back
Top