473,511 Members | 15,364 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Calling AddHandler more than once

When a document is to be printed I call a method that contains an AddHandler
statement.

I just realized that if a second copy is to be printed the method is called
and the AddHandler is executed again.

Is doing AddHandler a second time wrong?

I did check and even though I do AddHandler 3 times the handler is only
called once.

Should I do a RemoveHandler after I'm finished with the handler so next time
the AddHandler will not be adding a duplicate?
Thanks
Nov 21 '05 #1
2 2756
You should show the code in question.

However, calling AddHandler on the same object/method more then once, will
cause that method to be executed the # of times AddHandler is called.

Normally what happens it that all the event handlers for an object are
created once when the object is instantiated, and that is it. Doing this,
your handler would only be added once when the object is created, and that's
it.

" Just Me" <ne********@a-znet.com> wrote in message
news:eh*************@TK2MSFTNGP12.phx.gbl...
When a document is to be printed I call a method that contains an AddHandler statement.

I just realized that if a second copy is to be printed the method is called and the AddHandler is executed again.

Is doing AddHandler a second time wrong?

I did check and even though I do AddHandler 3 times the handler is only
called once.

Should I do a RemoveHandler after I'm finished with the handler so next time the AddHandler will not be adding a duplicate?
Thanks

Nov 21 '05 #2
Thanks for the help
"Marina" <so*****@nospam.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
You should show the code in question.

However, calling AddHandler on the same object/method more then once, will
cause that method to be executed the # of times AddHandler is called.

Normally what happens it that all the event handlers for an object are
created once when the object is instantiated, and that is it. Doing this,
your handler would only be added once when the object is created, and that's it.

" Just Me" <ne********@a-znet.com> wrote in message
news:eh*************@TK2MSFTNGP12.phx.gbl...
When a document is to be printed I call a method that contains an

AddHandler
statement.

I just realized that if a second copy is to be printed the method is

called
and the AddHandler is executed again.

Is doing AddHandler a second time wrong?

I did check and even though I do AddHandler 3 times the handler is only
called once.

Should I do a RemoveHandler after I'm finished with the handler so next

time
the AddHandler will not be adding a duplicate?
Thanks


Nov 21 '05 #3

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

Similar topics

2
6599
by: mark | last post by:
I am developing an application in .Net C# that needs to restore a number of tool windows to some previous location and size. The problem I have is that when I create the form and set the Location...
2
3274
by: MLS | last post by:
The documentation on dynamic handlers comes across as abiguous. Perhaps somebody could help set me straight? I have a situation where I need to dynamically create several usercontrols of the...
15
4004
by: Paul Mars | last post by:
I am creating a user selectable quantity of buttons at run time and need to respond to their click events. My code: Dim btnButton as Button (global) Then in a sub: For intNumBtnsDown = 0...
12
7052
by: Ron | last post by:
Greetings, I am trying to understand the rational for Raising Events instead of just calling a sub. Could someone explain the difference between the following 2 scenarios? Why would I want to...
7
2816
by: Jim Hubbard | last post by:
What is the reason for using AddHandler as opposed to simply writing the needed code in the event you are adding a handler to?
12
7106
by: Tom | last post by:
I use dynamically created controls all the time. I.E. I create the control in code then use AddHandler to add the necessary delegates for processing (like Click, etc). Does one have to call...
15
2032
by: Nathan Sokalski | last post by:
I have a section of my code that dynamically creates LinkButtons to allow the user to go to the page containing a question they have not answered. The code that creates the LinkButton is called, as...
15
8170
by: =?Utf-8?B?VG9tIENvcmNvcmFu?= | last post by:
I've been led to believe by several articles, particularly Eric Gunnerson's C# Calling Code Dynamically, that calling a method dynamically through Reflection was much slower than through a...
0
7242
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
7138
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
7353
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,...
1
7075
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
7508
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
3222
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...
0
1572
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
781
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
446
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.