473,557 Members | 2,746 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Event handlers

Hello!

I know it's possible to have several event handler for a single event but I
can't
see any point using several event handler for this.

I'm probably wrong so can anybody tell me what advantage it might give using
several
event handler for a single event.

//Tony
Aug 7 '08 #1
6 2008
On Aug 7, 7:40*am, "Tony Johansson" <johansson.ande rs...@telia.com >
wrote:
I know it's possible to have several event handler for a single event butI
can't see any point using several event handler for this.

I'm probably wrong so can anybody tell me what advantage it might give using
several event handler for a single event.
Suppose two completely separate pieces of code both want to react to a
button being clicked. One might be performing the normal user
interface interaction, and the other might be logging all UI
interaction for usability reasons. How would you do that without
multiple event handlers?

Another example: the AppDomain.Domai nUnloaded event. How can you
possibly be sure that only one piece of code will be interested in the
timing of AppDomain unloading?

Another example: Marc Gravell and I developed "Push LINQ" where data
is effectively pushed through predicates etc rather than pulled.
Handlers are registered to say they're interested in seeing data being
produced (and the "end of data" event). Using multiple event handlers
attached to the same event, you can compute several aggregates on the
same stream of data incredibly easily.

Having multiple event handlers doesn't come up *very* often, but it's
handy to be able to do it, and the way that delegates work make it
simple to achieve.

Jon
Aug 7 '08 #2
Hello!
If I have n event handlers will these always be called in the same sequence
as they subscribe to the event

//Tony

"Jon Skeet [C# MVP]" <sk***@pobox.co mskrev i meddelandet
news:b7******** *************** ***********@z6g 2000pre.googleg roups.com...
On Aug 7, 7:40 am, "Tony Johansson" <johansson.ande rs...@telia.com >
wrote:
I know it's possible to have several event handler for a single event but
I
can't see any point using several event handler for this.

I'm probably wrong so can anybody tell me what advantage it might give
using
several event handler for a single event.
Suppose two completely separate pieces of code both want to react to a
button being clicked. One might be performing the normal user
interface interaction, and the other might be logging all UI
interaction for usability reasons. How would you do that without
multiple event handlers?

Another example: the AppDomain.Domai nUnloaded event. How can you
possibly be sure that only one piece of code will be interested in the
timing of AppDomain unloading?

Another example: Marc Gravell and I developed "Push LINQ" where data
is effectively pushed through predicates etc rather than pulled.
Handlers are registered to say they're interested in seeing data being
produced (and the "end of data" event). Using multiple event handlers
attached to the same event, you can compute several aggregates on the
same stream of data incredibly easily.

Having multiple event handlers doesn't come up *very* often, but it's
handy to be able to do it, and the way that delegates work make it
simple to achieve.

Jon
Aug 7 '08 #3
On Aug 7, 9:54*am, "Tony Johansson" <johansson.ande rs...@telia.com >
wrote:
If I have n event handlers will these always be called in the same sequence
as they subscribe to the event
That depends on the implementation of the event's add/remove accessors
- but with any sane implementation will use the same sequence, as
that's the natural behaviour of Delegate.Combin e/Remove.

Jon
Aug 7 '08 #4
I'll have to check out your push linq. Sounds interesting.

....
Another example: Marc Gravell and I developed "Push LINQ" where data
is effectively pushed through predicates etc rather than pulled.
Handlers are registered to say they're interested in seeing data being
produced (and the "end of data" event). Using multiple event handlers
attached to the same event, you can compute several aggregates on the
same stream of data incredibly easily.
.....
Aug 8 '08 #5
William Stacey [C# MVP] <wi************ @gmail.comwrote :
I'll have to check out your push linq. Sounds interesting.
My current best attempt to explain it is:

http://msmvps.com/blogs/jon_skeet/ar...uot-push-quot-
linq-revisited-next-attempt-at-an-explanation.asp x

Or you can just look at the code, of course:
http://pobox.com/~skeet/csharp/miscutil

--
Jon Skeet - <sk***@pobox.co m>
Web site: http://www.pobox.com/~skeet
Blog: http://www.msmvps.com/jon.skeet
C# in Depth: http://csharpindepth.com
Aug 8 '08 #6
Thanks. The name makes me think of a push-sql feature I have wanted before.
Something like:
from rec in db.Table1.Inser t
where rec.Name != null
select into somedelegate();

So the db will push insert events and data back to my client delegate async.
Kinda like a CCR Selector, but instead of a port/queue, the queue is the db
table. Would make apps like outlook with caching new items locally from
some time T forward kinda ~easy. I guess another way to look it would be a
generic notification system against various providers (sql, news, pop3, etc)
but with linq.

"Jon Skeet [C# MVP]" <sk***@pobox.co mwrote in message
news:MP******** *************@m snews.microsoft .com...
William Stacey [C# MVP] <wi************ @gmail.comwrote :
>I'll have to check out your push linq. Sounds interesting.

My current best attempt to explain it is:

http://msmvps.com/blogs/jon_skeet/ar...uot-push-quot-
linq-revisited-next-attempt-at-an-explanation.asp x

Or you can just look at the code, of course:
http://pobox.com/~skeet/csharp/miscutil

--
Jon Skeet - <sk***@pobox.co m>
Web site: http://www.pobox.com/~skeet
Blog: http://www.msmvps.com/jon.skeet
C# in Depth: http://csharpindepth.com
Aug 11 '08 #7

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

Similar topics

10
3573
by: tony kulik | last post by:
This code works fine in ie and opera but not at all in Mozilla. Anybody got a clue as to how to get it right? <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <script language="JavaScript" type="text/javascript"> function show(that) { if (box.style.visibility=='hidden') { that.style.visibility = 'visible'}; }
8
3117
by: Dennis C. Drumm | last post by:
I have a class derived from a SortedList called SystemList that contains a list of objects indexed with a string value. The definition of the objects contained in the SortedList have a boolean field and an event that is fired if the boolean field value changes. The derived SortedList class has an override for the Add method. The Add...
18
4816
by: bhavin | last post by:
Hi, Can someone point me to some good best practices kind of documentation on use of events compared to method overriding. Ex. In Windows Forms when should i have an event handler for Paint, and when should i override OnPaint? I have to implement added functionality in a child class, and am in two minds .. to have the parent fire an event,...
13
3489
by: Charles Law | last post by:
Mr "yEaH rIgHt" posted the following link about a week ago in answer to my question about removing event handlers. > http://www.vbinfozine.com/t_bindevt.shtml Following on from that post, the following issues still exist. The article shows how to find methods on a receiver that match the pattern OnXXXX given the sender. It loops through...
5
3861
by: Amit | last post by:
Hello! Is it possible to find how many event handlers an event has at runtime? How about finding whether or not an event has event handlers? In C# you can compare the event with null to check if it has event handlers, but I can't find the equivalent in VB. Thanks Amit
6
28112
by: Kevin Attard | last post by:
I am using a GridView inside a UserControl which has a template column for deleting the rows. Before databinding the gridview i am attaching the RowCommand and RowDataBound event. I am using the RowDataBound event to set the commandargument of the delete button. The event is being fired and works fine. When I press the delete button, the...
16
2492
by: Hamed | last post by:
Hello I am developing a utility to be reused in other programs. It I have an object of type Control (a TextBox, ComboBox, etc.) that other programmers use it in applications. they may set some of properties or assign event handlers. I need to be able to clone the manipulated control at runtime. I could use the Clone method of some...
14
8586
by: Hamed | last post by:
Hello It seems that I should implement ICloneable to implement my own clone object. the critical point for me is to make a control object based on another control object that all of its event handlers are set like the old one. Is there a way to do this job? For example, is there a way to use EventInfo object to get all event handlers of...
6
2108
by: Jake K | last post by:
Where is the best place to define event handlers? I need to define event handlers for a COM object referenced in my project and am doing so in the fowm load. Is this the best place?
0
7626
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7549
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7830
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8061
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7591
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7911
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5454
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5172
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3599
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...

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.