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!

Re: Delegates & Events by Stoitcho

Stoitcho
Wed Jun 23 13:37:35 CDT 2004

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.

--
HTH
Stoitcho Goutsev (100) [C# MVP]


"Kyle Jedrusiak" <kyle.jedrusiak@princetoninformation.com.NO_SPAM> wrote in
message news:%23nAwXsUWEHA.3120@TK2MSFTNGP12.phx.gbl...
> 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!
>
>