Say I have a class that can fire some event like so
public SomeTypeOfEvent SomeEvent;
public delegate void SomeTypeOfEvent();
public void FooBar()
{
if (SomeEvent != null)
SomeEvent();
}
Is this the correct way to check to see if the SomeEvent
delegate has any subscribers? I faintly remember being told a few times that this is not correct because between the checking of the delegate and its firing the subscriber(s) to the event could be removed.
What is the proper/accepted way to check to see if a delegate is null?