Real Software Forums
http://forums.realsoftware.com/

AddHandler / RemoveHandler
http://forums.realsoftware.com/viewtopic.php?f=1&t=47854
Page 1 of 1

Author:  eliott [ Sun May 12, 2013 4:07 am ]
Post subject:  AddHandler / RemoveHandler

What is the best way to safely remove an event handler set by AddHandler if you don't know if it already has been removed? For a long time now I've used the following code:
#pragma BreakOnExceptions Off   // For debugging purposes
Try
RemoveHandler someObject.Action, AddressOf HandleAction
Catch err
// do nothing
End
#pragma BreakOnExceptions Default
This works fine but it needs quite a few rows of code where one should be sufficient. Does anybody have a better way to do this?

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/