Calling AddHandler more than once

  • Thread starter Thread starter Just Me
  • Start date Start date
J

Just Me

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
 
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.
 
Thanks for the help


Marina said:
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.
 
Back
Top