How to reverse the flow of event calling?

  • Thread starter Thread starter Jack Wright
  • Start date Start date
J

Jack Wright

Dear All,
When an application programmer subscribes to an event...I would like
the execution to take place in a FILO mechanism...f.e.x.
this.button1.Click += new System.EventHandler(this.MyOwnClick );

this.button1.Click += new System.EventHandler(this.button1_Click );

when button1.Click() event is called...
I would like that button1_Click method be called before
this.MyOwnClick...

How do I achieve that?

Please help...

TALIA

Many Regards
Jack
 
I believe eventhandlers are executed asynchronously, so I think you should
use synchronous delegates
 
I believe eventhandlers are executed asynchronously, so I think you should
use synchronous delegates

Are they?

From MSDN
http://msdn.microsoft.com/library/d.../cpref/html/frlrfSystemDelegateClassTopic.asp

"The invocation list of a delegate is an ordered set of delegates in which
each element of the list invokes exactly one of the methods invoked by the
delegate. An invocation list can contain duplicate methods. During an
invocation, a delegate invokes methods in the order in which they appear in
the invocation list. A delegate attempts to invoke every method in its
invocation list; duplicates are invoked once for each time they appear in
the invocation list. Delegates are immutable; once created, the invocation
list of a delegate does not change."

Etienne Boucher
 
....just subscribe to the event once and call the method directly, i.e.


this.button1.Click += new System.EventHandler(this.MyOwnClick );

private void MyOwnClick (object sender, ...)
{
this.button1_Click (sender, ...);

... code for MyOwnClick
}
 
my mistake, thanx for pointing it out...

Etienne Boucher said:
Are they?

From MSDN
http://msdn.microsoft.com/library/d.../cpref/html/frlrfSystemDelegateClassTopic.asp

"The invocation list of a delegate is an ordered set of delegates in which
each element of the list invokes exactly one of the methods invoked by the
delegate. An invocation list can contain duplicate methods. During an
invocation, a delegate invokes methods in the order in which they appear in
the invocation list. A delegate attempts to invoke every method in its
invocation list; duplicates are invoked once for each time they appear in
the invocation list. Delegates are immutable; once created, the invocation
list of a delegate does not change."

Etienne Boucher
 
Back
Top