コード例 #1
0
        protected override void OnClosing(CancelEventArgs e)
        {
            isDisposed = true;

            if (networkDiscovery != null)
            {
                networkDiscovery.Dispose();
                networkDiscovery = null;
            }

            lock (this)
            {
                if (inputTimer != null)
                {
                    inputTimer.Dispose();
                    inputTimer = null;
                }

                if (socket != null)
                {
                    socket.Dispose();
                    socket = null;
                }
            }

            if (gzipStream != null)
            {
                gzipStream.Dispose();
                gzipStream = null;
            }

            settingsOverlay.SaveSettings();
            base.OnClosing(e);
        }
        void Exit(object sender, EventArgs e)
        {
            // dispose
            lock (this)
            {
                isDisposed = true;

                if (timer != null)
                {
                    timer.Stop();
                    timer.Tick -= Timer_Tick;
                    timer.Dispose();
                    timer = null;
                }

                if (networkDiscovery != null)
                {
                    networkDiscovery.Dispose();
                    networkDiscovery = null;
                }

                if (socket != null)
                {
                    socket.Dispose();
                    socket = null;
                }

                if (graphics != null)
                {
                    graphics.Dispose();
                    graphics = null;
                }

                if (bitmap != null)
                {
                    bitmap.Dispose();
                    bitmap = null;
                }
            }

            // exit
            trayIcon.Visible = false;
            Application.Exit();
        }