Office .NET Eventhandler

I have an event handler in code that, as I see it, is called several times when I expect it to be called only once.

In the past, this was due to the fact that I defined the delegation in the wrong place (so much so that one delegate is added to the event processing list), but in this case it is set only once (in the class constructor).

Instead of continuing to manually search my error code, is there a (simple) pragmatic approach that I can decide to determine where event handlers are assigned?

+5
source share
5 answers

You can replace the default value:

public event EventHandler MyEvent;

... from

private EventHandler _myEvent;

public event EventHandler MyEvent
{
    add { _myEvent += value; }
    remove { _myEvent -= value; }
}

/ .

+18

vb.net, , , handles?

, .

+1

Resharper, " ".

+1
+1

( Visual Studio, ) , .

0

All Articles