2

Imagine an event

private event EventHandler SampleEvent;

which should be raised. I know 3 ways to do this, but I don't get the difference between two of them which are

SampleEvent(this, EventArgs.Empty);

and

SampleEvent.Invoke(this, EventArgs.Empty);

What is the difference between those two and what advantages and disadvantages does either method have?

Rob
  • 919
  • 7
  • 16

1 Answers1

1

Since event is represented by a delegate internally, Invoke method is present there. Omitting it in calling is just a compiler trick to have a more readable code.

Ondrej Janacek
  • 12,486
  • 14
  • 59
  • 93