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

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -