473,395 Members | 2,689 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.

Are multiple events expensive?

Bob
Hi,
I have a newbie question on event listening. I have a form that is
monitoring progress in an application. The application consists of
many classes, multithreaded, etc. The form listens for events on the
main executing class, which in turn listens for events on classes it
uses, etc, so that an event might have to propagate through several
layers of event listeners and new events to make its way back to the
form. I am wondering whether this is computationally expensive (ie
raising multiple events) or if it is an ok way to program?

Thanks,
Bob

Mar 22 '07 #1
3 2073
"Bob" <bs********@yahoo.comwrote in message
news:11**********************@l77g2000hsb.googlegr oups.com...
I have a newbie question on event listening. I have a form that is
monitoring progress in an application. The application consists of
many classes, multithreaded, etc. The form listens for events on the
main executing class, which in turn listens for events on classes it
uses, etc, so that an event might have to propagate through several
layers of event listeners and new events to make its way back to the
form. I am wondering whether this is computationally expensive (ie
raising multiple events) or if it is an ok way to program?
Listening for an event does not have any cost, that is, nothing happens
until the event is fired. When the events are raised, the cost is roughly
equivalent to method calls (imagine that instead of using an event that
raises another event you had a method that called another method, and so
on).

Mar 22 '07 #2
Bob
On Mar 22, 2:01 am, "Alberto Poblacion" <earthling-
quitaestoparacontes...@poblacion.orgwrote:
"Bob" <bshumsk...@yahoo.comwrote in message

news:11**********************@l77g2000hsb.googlegr oups.com...
I have a newbie question on event listening. I have a form that is
monitoring progress in an application. The application consists of
many classes, multithreaded, etc. The form listens for events on the
main executing class, which in turn listens for events on classes it
uses, etc, so that an event might have to propagate through several
layers of event listeners and new events to make its way back to the
form. I am wondering whether this is computationally expensive (ie
raising multiple events) or if it is an ok way to program?

Listening for an event does not have any cost, that is, nothing happens
until the event is fired. When the events are raised, the cost is roughly
equivalent to method calls (imagine that instead of using an event that
raises another event you had a method that called another method, and so
on).
Great, thanks!

Mar 22 '07 #3
Event delegate assignments take up some memory, as delegates themselves and
the containment of them in an event subscription stack aren't free, but a
handful of delegate assignments won't matter.

As Alberto mentioned, the performance hit is on the delegates' executions.
There, the impact is more or less measurable by how often your event
handlers are executed and what exactly they do.

Jon
"Bob" <bs********@yahoo.comwrote in message
news:11**********************@l77g2000hsb.googlegr oups.com...
Hi,
I have a newbie question on event listening. I have a form that is
monitoring progress in an application. The application consists of
many classes, multithreaded, etc. The form listens for events on the
main executing class, which in turn listens for events on classes it
uses, etc, so that an event might have to propagate through several
layers of event listeners and new events to make its way back to the
form. I am wondering whether this is computationally expensive (ie
raising multiple events) or if it is an ok way to program?

Thanks,
Bob

Mar 23 '07 #4

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

Similar topics

3
by: Bob | last post by:
Is there an interface or events in the system that occurs pre and post garbage collection that one of my objects can attach to? I need to know in my application when garbage collection is about to...
5
by: Shabam | last post by:
I'm having a calendar feature developed whereby users can add recurring events. These recurring events can have start and end dates, meaning they will recur only within a date range. For...
2
by: news.hp.com | last post by:
I have situation where I need to copy multiple records (only certain fields) from a Rules table to an Events table based on a selection identified in a combo box. When the selection is made in a...
15
by: Iced Crow | last post by:
In C# I know that you can use delegates to assing multiple addresses of sub and functions to a delegate and have it fire multiple procedures... How do I do this in VB? I only know of assigning...
4
by: Frank | last post by:
Hello. In the early stages of developing a server application that will be required to send events to multiple client applications that will be running on different PC's. I'm wondering what the...
12
by: cj | last post by:
I would like to have menu items a main menu bar that represent the days of the week. When you click on them they alternate from checked to unchecked. Right now I have 7 subs that look like this...
9
by: Gummy | last post by:
Hello, I created a user control that has a ListBox and a RadioButtonList (and other stuff). The idea is that I put the user control on the ASPX page multiple times and each user control will...
35
by: keerthyragavendran | last post by:
hi i'm downloading a single file using multiple threads... how can i specify a particular range of bytes alone from a single large file... for example say if i need only bytes ranging from...
7
by: der_grobi | last post by:
That is the Problem: I have an ASP.NET Webapplicatipon where I can upload single files to the Server. That works fine. But now, I want to Upload multiple files. I know the path of the files, i...
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
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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.