|Synopsis:||Always check an event handler delegate for null|
|Category:||Delegates and events|
An event that has no subscribers is null. So before invoking, always make sure that the delegate list represented by the event variable is not null. Invoke using the null conditional operator, because it additionally prevents conflicting changes to the delegate list from concurrent threads.
Tip You can prevent the delegate list from being empty altogether. Simply assign an empty delegate like this: