vb.net - How can I know if a .net event is already handled? -
i've written code handle event follows:
addhandler myobject.myevent, addressof myfunction
it seemed working @ first, when ran debugger, discovered oftentimes, myfunction
run several times each time myobject.myevent
fired. figured out had allowed code add event handler run more once, resulting in behavior.
is there way can this?
if myobject.myevent not handled addhandler myobject.myevent, addressof myfunction end if
assuming it's not code that's publishing event, can't. idea subscribers isolated each other - can't find out other event subscribers, raise event etc.
if problem you're adding own handler multiple times, should able fix keeping track of whether you have added handler. steven's idea of removing handler before adding interesting workaround: it's valid attempt remove handler when isn't subscribed. however, i'd regard workaround app not knowing should doing. it's quick short-term fix, i'd worried leaving in longer term.
Comments
Post a Comment