Propagating events

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

What is the correct technique when firing events that must be propagated up
the call stack?

I have a class A that instantiates a class B that instantiates class C. C is
firing an event that A needs to response to. I have implemented it this way:

C fires event CEvent. B (subscriber of CEvent) picks it up and fires its own
event BEvent by just passing through the event args from CEvent. A
(subscriber of BEvent) picks up BEvent and takes proper action.

Is this the correct technique ot is it another and more convenient way to do
it?
 
Class B can just catch the event and throw it in the catch block so that it
is propogated to B's parent, that is class A.
 
Sameeksha : the op's question was Events NOT Exceptions.
========

Bevo : your approach is perfectly acceptable
====
 
Hi,

This method is good, B has two options, either expose C as public and allow
it to be directly accesible to the callers or just keep it private and just
derefine C's members he wants to be accesible to clients using B.



cheers,
 

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