In my application events can be raised in one thread, but delegates
can be added to the events from another thread. I wonder if I really
have to synchronize the event raising and all += / -= operations.
Do I have to write:
lock ( source.NewInput ) {
source.NewInput += this.NewInputHandler;
}
and
protected virtual void OnNewInput(object sender, NewInputEventArgs e)
{
if (NewInput != null)
{
lock ( NewInput )
{
NewInput(this, e);
}
}
}
???
Without the locks my application works correctly, but I know this
doesn't proof anything.
I cannot find any info on the web, because word "event" has too many
meanings.