30.
What is the thread-safe way to fire an event?
View Description
Normally we fire event this way: if(myEvent!=null) myEvent(sender, e); But in multi-threaded environment there is a possibility that a client oversubscribes from the event after we passed the check myEvent!=null. To avoid the race condition we can store the event to temporary variable and then work with it. Copying of delegates is an atomic operation in terms of multi-threading.