By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,239 Members | 1,503 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,239 IT Pros & Developers. It's quick & easy.

Calling AddHandler more than once

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.