PC Review


Reply
Thread Tools Rate Thread

Can I stop other event handlers from receiving an event?

 
 
=?Utf-8?B?TXJOb2JvZHk=?=
Guest
Posts: n/a
 
      12th Nov 2004
If i add an event handler to a particular event on a Control, can I consume
events that are triggered so any other handlers registered to the same event
do not process their code?
 
Reply With Quote
 
 
 
 
Kumar Reddi
Guest
Posts: n/a
 
      12th Nov 2004
Yeah, When you are attaching an event handler to an event, you use "+="
syntax, this adds to the list of handlers, if you simply use "=", that is
the only event handler that can recieve the event


"MrNobody" <(E-Mail Removed)> wrote in message
news:7488D6CA-34DB-4150-8375-(E-Mail Removed)...
> If i add an event handler to a particular event on a Control, can I

consume
> events that are triggered so any other handlers registered to the same

event
> do not process their code?



 
Reply With Quote
 
Stoitcho Goutsev \(100\) [C# MVP]
Guest
Posts: n/a
 
      13th Nov 2004
Hi Kamur,

In the case of events += -= are translated by the compiler into calls to add
and remove event accessors. Using = with events on the other hand makes the
compiler t ogenerate an error message. Using = operator is possible when it
goes for variables of some delegate type, but not for events.

To answer to the original poster.... No, it is not possible. Even if it was
you cannot know how many handlers has been already registered, so to cancel
the handlers invokation won't lead to any good.


--
Stoitcho Goutsev (100) [C# MVP]

"Kumar Reddi" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Yeah, When you are attaching an event handler to an event, you use "+="
> syntax, this adds to the list of handlers, if you simply use "=", that is
> the only event handler that can recieve the event
>
>
> "MrNobody" <(E-Mail Removed)> wrote in message
> news:7488D6CA-34DB-4150-8375-(E-Mail Removed)...
>> If i add an event handler to a particular event on a Control, can I

> consume
>> events that are triggered so any other handlers registered to the same

> event
>> do not process their code?

>
>



 
Reply With Quote
 
Kumar Reddi
Guest
Posts: n/a
 
      13th Nov 2004
Hi Goutsev,
You are right. My mistake. Was not thinking when I typed the response

Kumar
"Stoitcho Goutsev \(100\) [C# MVP]" <(E-Mail Removed)> wrote in message news:<#(E-Mail Removed)>...
> Hi Kamur,
>
> In the case of events += -= are translated by the compiler into calls to add
> and remove event accessors. Using = with events on the other hand makes the
> compiler t ogenerate an error message. Using = operator is possible when it
> goes for variables of some delegate type, but not for events.
>
> To answer to the original poster.... No, it is not possible. Even if it was
> you cannot know how many handlers has been already registered, so to cancel
> the handlers invokation won't lead to any good.
>
>
> --
> Stoitcho Goutsev (100) [C# MVP]
>
> "Kumar Reddi" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Yeah, When you are attaching an event handler to an event, you use "+="
> > syntax, this adds to the list of handlers, if you simply use "=", that is
> > the only event handler that can recieve the event
> >
> >
> > "MrNobody" <(E-Mail Removed)> wrote in message
> > news:7488D6CA-34DB-4150-8375-(E-Mail Removed)...
> >> If i add an event handler to a particular event on a Control, can I

> consume
> >> events that are triggered so any other handlers registered to the same

> event
> >> do not process their code?

> >
> >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to find event handlers of given event using reflection Grzegorz Danowski Microsoft C# .NET 2 9th Jan 2007 09:27 PM
Multiple Event Handlers for Single Event =?Utf-8?B?cGFnYXRlcw==?= Microsoft C# .NET 2 24th Jul 2006 07:46 PM
How do I stop IE 6 from parsing all javascript on event handlers... AirVent Windows XP Internet Explorer 0 29th Mar 2006 02:57 AM
Newbie Question: One event triggers two event handlers MattNC Microsoft C# .NET 2 30th Mar 2005 11:44 PM
Multiple Event Handlers for a Single Event - Newbie Question. Andy Cooper Microsoft VB .NET 8 2nd Jan 2004 04:26 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:14 AM.