|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. Furthermore, to prevent conflicting changes from concurrent threads, use a temporary variable to prevent concurrent changes to the delegate.
Tip You can prevent the delegate list from being empty altogether. Simply assign an empty delegate like this: