I have come into the habit to remove the handler immediately after use, when possible.
For instance, in a timer, I will do addhandler just before starting the timer, and removehandler from within the handler method when I stop the timer or when it is in single mode. That way It don’t have to clean up in cancelclose or close.
[quote=379739:@Michel Bujardet]I have come into the habit to remove the handler immediately after use, when possible.
For instance, in a timer, I will do addhandler just before starting the timer, and removehandler from within the handler method when I stop the timer or when it is in single mode. That way It don’t have to clean up in cancelclose or close.[/quote]
Agreed. So if the socket connects, then I do its thing and then remove the handler. But if the socket doesn’t connect then I need a way to remove it as well otherwise it would stick around.