I found an example of a simple event dispatch. I do not understand the lineEventHandler<string> handler = MyEvent;
Why do they need to define a link to the event, and not just use it myEventto call?
The code
public event EventHandler<string> MyEvent;
protected void SendEvent(string e)
{
EventHandler<string> handler = MyEvent;
if (handler != null)
{
handler(this, e);
}
}
source
share