public void iTunes() { itunes = new iTunesAppClass(); aboutToPromptUserToQuitEvent = new _IiTunesEvents_OnAboutToPromptUserToQuitEventEventHandler(itunes_OnAboutToPromptUserToQuitEvent); cOMCallsDisabledEvent = new _IiTunesEvents_OnCOMCallsDisabledEventEventHandler(itunes_OnCOMCallsDisabledEvent); cOMCallsEnabledEvent = new _IiTunesEvents_OnCOMCallsEnabledEventEventHandler(itunes_OnCOMCallsEnabledEvent); databaseChangedEvent = new _IiTunesEvents_OnDatabaseChangedEventEventHandler(itunes_OnDatabaseChangedEvent); playerPlayEvent = new _IiTunesEvents_OnPlayerPlayEventEventHandler(itunes_OnPlayerPlayEvent); playerPlayingTrackChangedEvent = new _IiTunesEvents_OnPlayerPlayingTrackChangedEventEventHandler(itunes_OnPlayerPlayingTrackChangedEvent); playerStopEvent = new _IiTunesEvents_OnPlayerStopEventEventHandler(itunes_OnPlayerStopEvent); quittingEvent = new _IiTunesEvents_OnQuittingEventEventHandler(itunes_OnQuittingEvent); soundVolumeChangedEvent = new _IiTunesEvents_OnSoundVolumeChangedEventEventHandler(itunes_OnSoundVolumeChangedEvent); userInterfaceEnabledEvent = new _IiTunesEvents_OnUserInterfaceEnabledEventEventHandler(itunes_OnUserInterfaceEnabledEvent); // NOTE: did not see any difference in maintaining these individual handler variables // as opposed to unregistering -= new handlers in the OnAboutToPromptToQuit handler itunes.OnAboutToPromptUserToQuitEvent += aboutToPromptUserToQuitEvent; itunes.OnCOMCallsDisabledEvent += cOMCallsDisabledEvent; itunes.OnCOMCallsEnabledEvent += cOMCallsEnabledEvent; itunes.OnDatabaseChangedEvent += databaseChangedEvent; itunes.OnPlayerPlayEvent += playerPlayEvent; itunes.OnPlayerPlayingTrackChangedEvent += playerPlayingTrackChangedEvent; itunes.OnPlayerStopEvent += playerStopEvent; itunes.OnQuittingEvent += quittingEvent; itunes.OnSoundVolumeChangedEvent += soundVolumeChangedEvent; itunes.OnUserInterfaceEnabledEvent += userInterfaceEnabledEvent; AllProps(itunes); reset = new ManualResetEvent(false); // waiting for iTunes to quit reset.WaitOne(); }