Delegates & Events

K

Kyle Jedrusiak

I need some clarrification.

I have a class called ChatManager that will manage the interaction between
the ClientUI (WinForm) and the chat server.

The ChatManager will have a number of public events.

When the ClientUI is instantiated it will subscribe to these events
providing its own methods to be used as event handlers.

In the ChatManager code when I raise a particular event...which in turn
calls the delegate...

Will the delegate execute on the same thread as the ClientUI (which it must
do to update the WinForm) or does it execute on some other thread?

Kyle!
 
S

Stoitcho Goutsev \(100\) [C# MVP]

Hi Kyle,
Will the delegate execute on the same thread as the ClientUI (which it must
do to update the WinForm) or does it execute on some other thread?

No, the delegates will execute on the calling thread. ClientUI has to
schedule the code for updating the UI to be executed by the UI thread. Since
it's a WinForm control it has no problems to do that via calling either
Control.Invoke or Control.BeginInvoke.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top