So you need to raise an event, and wanna do it in a threadsafe way, or safer way :)
Not so long ago i wrote this code :
...
public event EventHandler Save;
...
private void OnSave(EventArgs e)
{
if(Save != null) Save(this,EventArgs.Empty);
}
What is wrong here, the fact that the point between the not null check and the eventual event raising can has changes in between.
So from now just write this :
private void OnSave(EventArgs e)
{
EventHandler handlers = Save;
if (handlers != null) handlers(this, e);
}
This makes a copy into the handlers variable and cannot change between check and raise.