void OnSettingsSaving() { // make a temporary copy of the event to avoid possibility of // a race condition if the last subscriber unsubscribes // immediately after the null check and before the event is raised SettingsEventHandler handler = null; lock (this) { handler = SettingsSaving; } // raise event if (handler != null) { handler(this); } }
public DelegateHandler(SettingsGroup sgObj) { SettingsEventHandler sehObj1 = new SettingsEventHandler(MySettingsEventHandler); sgObj.Changed += sehObj1; }