troubleshooting Question

event binding/chaining

Avatar of DaFou
DaFou asked on
5 Comments1 Solution245 ViewsLast Modified:
Hi All,

I have 3 classes. class A, B and C. with all 3 classes having the event OnSomethingHappend.
A.OnSomethingHappend, B.OnSomethingHappend and C.OnSomethingHappend

C had a member of type B
B has a member of type A


How can i chain the event OnSomethingHappend from A all the way to C via B
So that if the event fires in a it is automaticly bubled up to C and fires there aswell.

I want to bind the events somehow rather then passing on the event.
S0 what i dont want to do is create an event handler in class C that responds to the event in class B that is fired when the event in class A happens.

So code i dont want to use is like this for
class C
B.OnSomethingHappend += new B.SomethingHappend(_B_OnSomethingHappend);

void _B_OnSomethingHappend(object sender, EventArgs eventArgs)
            //do stuff when event in class A fired

Class B
A.OnSomethingHappend += new A.SomethingHappend(_A_OnSomethingHappend);

void _A_OnSomethingHappend(object sender, EventArgs eventArgs)
            OnSomethingHappend(this, new EventArgs());

Is there a more cleaner way to bind/chain events?
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 5 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros