Multiple delegates

  • Thread starter Thread starter puneet4friends
  • Start date Start date
P

puneet4friends

A button is rgistered with four delegates. Which delegate will be
called first and why ?
 
A button is rgistered with four delegates. Which delegate will be
called first and why ?

"Registered"? In what way? Do you mean delegates have been subscribed
to the Click event? Or something else? You should be specific about
what you mean.

As far as the answer goes, you can easily observe the behavior yourself
to find out _what_ happens. See the documentation for events and
MulticastDelegate for an explanation.

Pete
 
Delegates are essentially linked lists. When you assign a method to a
Delegate, it is added to the list. The list is processed in order from first
to last.

--
HTH,

Kevin Spencer
Microsoft MVP

DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net
 
Delegates are essentially linked lists. When you assign a method to a
Delegate, it is added to the list. The list is processed in order from first
to last.
.....unless the code processing the list decides to do otherwise!
 
It's a linked list.

Yes, but the event source can do what it likes..
Typically it might just do:

given
public event EventHandler<EventArgs> TheEvent;
just call
TheEvent( this , EventArgs.Empty);

but it could do anything like, for example...

foreach( Delegate d in TheEvent.GetInvokationList() )
{
d.BeginInvoke(...)
}

which means it's doing them asynchronously, so the order of arrival
isn't guaranteed.

etc.
 

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

Back
Top