/// <summary> /// Dispose of all resources in an orderly fashion. /// </summary> public override void Dispose() { if (aboutBox != null) { aboutBox.Dispose(); aboutBox = null; } if (tracker != null) { tracker.Dispose(); tracker = null; } if (librarian != null) { librarian.CollectionChanged -= DoTaskCollectionChanged; librarian.Dispose(); librarian = null; } if (controller != null) { controller.LyricsProgressReport -= DoLyricsProgressReport; controller.LyricsUpdated -= DoLyricsUpdated; controller.Quiting -= DoQuiting; controller.TrackPlaying -= DoTrackPlaying; controller.TrackStopped -= DoTrackStopped; // if running from IDE force iTunes to shutdown, force COM detach. Poking around // in the debugger tends to destabalize the COM interface so we shut it down when // invoked from the Debugger to avoid any confusion. controller.Dispose(System.Diagnostics.Debugger.IsAttached); controller = null; } if (manager != null) { manager.KeyPressed -= ExecuteHotKeyAction; manager.Dispose(); manager = null; } if (trayIcon != null) { trayIcon.ContextMenu.Popup -= SetMenuItemStates; trayIcon.ContextMenu.Dispose(); trayIcon.ContextMenu = null; trayIcon.MouseDown -= DoTrayIconMouseDown; trayIcon.Dispose(); trayIcon = null; } base.Dispose(); isDisposed = true; }