473,396 Members | 2,147 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,396 software developers and data experts.

Can I stop other event handlers from receiving an event?

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?
Nov 16 '05 #1
3 7068
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" <Mr******@discussions.microsoft.com> wrote in message
news:74**********************************@microsof t.com...
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?

Nov 16 '05 #2
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" <Ku********@REMOVETHIS.gmail.com> wrote in message
news:eM**************@TK2MSFTNGP10.phx.gbl...
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" <Mr******@discussions.microsoft.com> wrote in message
news:74**********************************@microsof t.com...
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?


Nov 16 '05 #3
Hi Goutsev,
You are right. My mistake. Was not thinking when I typed the response

Kumar
"Stoitcho Goutsev \(100\) [C# MVP]" <10*@100.com> wrote in message news:<#0**************@tk2msftngp13.phx.gbl>...
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" <Ku********@REMOVETHIS.gmail.com> wrote in message
news:eM**************@TK2MSFTNGP10.phx.gbl...
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" <Mr******@discussions.microsoft.com> wrote in message
news:74**********************************@microsof t.com...
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?


Nov 16 '05 #4

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

Similar topics

0
by: Scott | last post by:
I'm using C# to build an application. 1) I have two windows forms, A and B. 2) A uses a DataSet read from SQL server. 3) The user presses a button on A to open B. 4) B is passed a pointer to...
10
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...
7
by: Neal Andrews | last post by:
Hi All, Does anyone know how to stop Events from being serialized in a class that uses the <Serializable()> attribute? I have tried using the <NonSerialized()> attribute but for some bizarre...
13
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...
9
by: Matt | last post by:
In many places in my application, I have a DataGridView which users can either enter data into or use as a method of navigation in a master/detail form view. I need a method of stopping the user...
51
by: Hans | last post by:
Hi all, Is there a way that the program that created and started a thread also stops it. (My usage is a time-out). E.g. thread = threading.Thread(target=Loop.testLoop) thread.start() ...
16
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...
14
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...
8
by: Richard Maher | last post by:
Hi, I am in a mouseup event for button A and I'd like to disable=false button B before starting some work. Is there anyway that an event for button B can then fire before my event processing for...
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
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
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
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...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.