473,395 Members | 1,568 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Propagating events

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?
Nov 17 '05 #1
3 1954
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.

"Bevo" wrote:
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?

Nov 17 '05 #2
Sameeksha : the op's question was Events NOT Exceptions.
========

Bevo : your approach is perfectly acceptable
====

--
Of all words of tongue and pen, the saddest are: "It might have been"

Bill.Richards @ greyskin .co .uk
http://greyskin.co.uk
"Sameeksha MCAD.Net" wrote:
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.

"Bevo" wrote:
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?

Nov 17 '05 #3
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,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Bevo" <Be**@discussions.microsoft.com> wrote in message
news:BF**********************************@microsof t.com...
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?

Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Vince C. | last post by:
Hi. I'd like to trap ADO Recordset object events in my ASP script (either VBS or JS, no preference). I've tried (in VBS) writing a Sub rs_RecordChangeComplete( adReason, cRecords, pError,...
8
by: Edward Diener | last post by:
Is it possible for a derived class to override a property and/or event of its base class ?
3
by: Sasha | last post by:
Hi everyone, Here is my problem: I have the following classes: - DataNode - this class is designed to hold some data and will be contained in a tree like data structure DataTree. When...
14
by: JPRoot | last post by:
Hi I use the following syntax to have events inherited from base to child classes which works nicely (virtual and override keyword on events). But I am wondering if it is a "supported" way of using...
2
by: Maria | last post by:
Hi Guys (and Gals) Bit of a newbie to C# here and I am having a problem which I am coming across. I need to capture when events are raised in child objects within a collection and raise them...
4
by: LP | last post by:
Hello! I am still transitioning from VB.NET to C#. I undertand the basic concepts of Delegates, more so of Events and somewhat understand AsyncCallback methods. But I need some clarification on...
11
by: Nicky Smith | last post by:
Hello, I'm studying a book on VB.net Win apps, and I'm reading a section on events and delegates and raising events. Is it just me, or is this not just subs dressed up as something else? I...
14
by: xoozlez | last post by:
Hi there, I have a registration form where I like to filter out the past events of 2007. This is the code I am using : strSQL = "SELECT EventID, EventName, EventDateBegin, EventDateEnd,...
1
by: swethak | last post by:
Hi, I am desiging the calendar application for that purpose i used the below code. But it is for only displys calendar. And also i want to add the events to calendar. In that code displys the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.