Example #1
0
        private void CloseApplication()
        {
            try
            {
                //Stop timers
                if (MusicStartTimer != null && MusicStartTimer.Enabled)
                {
                    MusicStartTimer.Stop();
                }
                if (MusicPopupTimer != null && MusicPopupTimer.Enabled)
                {
                    MusicPopupTimer.Stop();
                }
                //Ensure the task tray icon is disposed before closing
                trayIcon.Close();
                //Ensure the input listener is disposed
                input.Dispose();
            }
            catch (Exception ex)
            {
                Tools.LogError(ex);
            }

            //Shut down the entire application (all windows)
            //Application.Current.Shutdown(); //This sometimes gets a null reference exception
            Process.GetCurrentProcess().Kill();
        }
        // EVENT HANDLERS

        private void Window_Closed(object sender, EventArgs e)
        {
            input.Dispose();
        }