class Plane
{
public event EventHandler Land;
protected void OnLand()
{
if ( null != Land )
{
Land( this, null );
}
}
}
it is event handler best practice to do instead:
EventHandler temp = Land;
if ( null != temp )
{
temp( this, null );
}
Is that truly necessary? In what case could temp be different from Land?
In the case of multi-threaded access, I believe. If you don't cache the reference, another thread can null it out after your guard but before you fire.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With