private void MainWindow_FormClosing(object Sender, FormClosingEventArgs EventArgs) { if (!bAllowClose && Settings.bKeepInTray) { Hide(); EventArgs.Cancel = true; } else { for (int Idx = 0; Idx < TabControl.GetTabCount(); Idx++) { WorkspaceControl Workspace = (WorkspaceControl)TabControl.GetTabData(Idx); if (!Workspace.CanClose()) { EventArgs.Cancel = true; return; } } ActivationListener.OnActivate -= OnActivationListenerAsyncCallback; ActivationListener.Stop(); UpdateMonitor.OnUpdateAvailable -= OnUpdateAvailable; UpdateMonitor.Close(); // prevent race condition StopScheduleTimer(); Rectangle SaveBounds = (WindowState == FormWindowState.Normal)? Bounds : RestoreBounds; Settings.WindowRectangle = SaveBounds; Settings.bWindowVisible = Visible; Settings.Save(); } }
protected override void Dispose(bool bDisposing) { base.Dispose(bDisposing); if (Components != null) { Components.Dispose(); Components = null; } if (NotifyIcon != null) { NotifyIcon.Dispose(); NotifyIcon = null; } if (Log != null) { Log.Dispose(); Log = null; } if (UpdateMonitor != null) { UpdateMonitor.OnUpdateAvailable -= OnUpdateAvailableCallback; UpdateMonitor.Close(); // prevent race condition UpdateMonitor = null; } if (ActivationListener != null) { ActivationListener.OnActivate -= OnActivationListenerAsyncCallback; ActivationListener.Stop(); ActivationListener.Dispose(); ActivationListener = null; } if (MainWindowInstance != null) { MainWindowInstance.ForceClose(); MainWindowInstance = null; } if (DetectStartupProjectSettingsWindow != null) { DetectStartupProjectSettingsWindow.Close(); DetectStartupProjectSettingsWindow = null; } }