private void ApplicationHandler_TrayIcon(object sender, EventArgs e) { MenuItem item = (MenuItem)sender; if (item == exitButton) { BG_Notifaction.Visible = false; BG_Notifaction.Icon = null; BG_Notifaction.Dispose(); Thread.Sleep(100); SaveConfigs(); Environment.Exit(0); } else if (item == showHide) { Win32Api.Window.ShowWindow(myHandle, Win32Api.Window.SW_SHOW); } }
private void OnFormClosing(object sender, FormClosingEventArgs e) { if (ES_KeepAlive.Checked) { e.Cancel = true; myHandle = Process.GetCurrentProcess().MainWindowHandle; Win32Api.Window.ShowWindow(myHandle, Win32Api.Window.SW_HIDE); BG_Notifaction.BalloonTipTitle = "DNF金币比价器"; BG_Notifaction.BalloonTipText = "现在已经开始后台工作啦.~"; BG_Notifaction.ShowBalloonTip(3000); } else { BG_Notifaction.Visible = false; BG_Notifaction.Icon = null; BG_Notifaction.Dispose(); Thread.Sleep(100); } }
private void OnFormClosing(object sender, FormClosingEventArgs e) { e.Cancel = true; if (N_Background) { myHandle = Process.GetCurrentProcess().MainWindowHandle; Win32Api.Window.ShowWindow(myHandle, Win32Api.Window.SW_HIDE); BG_Notifaction.BalloonTipTitle = "DNF金币比价器"; BG_Notifaction.BalloonTipText = "现在已经开始后台工作啦.~"; BG_Notifaction.ShowBalloonTip(3000); } else if (!closing) { BG_Notifaction.Visible = false; BG_Notifaction.Icon = null; BG_Notifaction.Dispose(); closing = true; new Thread(() => { Thread.Sleep(1000); while (beginUpdate) { Thread.Sleep(100); } Invoke(new Action(() => { Close(); Dispose(); Environment.ExitCode = 10086; })); }) { IsBackground = true, Priority = ThreadPriority.Lowest, Name = "Cleaner thread" }.Start(); } }