Пример #1
0
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                // When the app exits we need to un-shift any modify keys that might
                // have been pressed or they'll still be stuck after exit
                SendInputCommand.ShiftKey("shift", false);
                SendInputCommand.ShiftKey("ctrl", false);
                SendInputCommand.ShiftKey("alt", false);
                SendInputCommand.ShiftKey("lwin", false);
                SendInputCommand.ShiftKey("rwin", false);

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

                if (_server != null)
                {
                    // remove our notification handler
                    _server.Notifications -= HandleSocketServerCallbacks;
                    _server.Dispose();
                }
                if (_client != null)
                {
                    // remove our notification handler
                    _client.Notifications -= HandleClientNotifications;
                    _client.Dispose();
                }

                if (_serialServer != null)
                {
                    _serialServer.Notifications -= HandleSerialServerNotifications;
                    _serialServer.Dispose();
                }
            }
            base.Dispose(disposing);
        }
Пример #2
0
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                // When the app exits we need to un-shift any modify keys that might
                // have been pressed or they'll still be stuck after exit
                Logger.Instance.Log4.Debug("Ensuring shift key modifiers are reset...");
                SendInputCommand.ShiftKey("shift", false);
                SendInputCommand.ShiftKey("ctrl", false);
                SendInputCommand.ShiftKey("alt", false);
                SendInputCommand.ShiftKey("lwin", false);
                SendInputCommand.ShiftKey("rwin", false);

                components?.Dispose();

                if (Server != null)
                {
                    // remove our notification handler
                    Server.Notifications -= serverSocketCallbackHandler;
                    Server.Dispose();
                }
                if (Client != null)
                {
                    // remove our notification handler
                    Client.Notifications -= clientSocketNotificationHandler;
                    Client.Dispose();
                }

                if (SerialServer != null)
                {
                    SerialServer.Notifications -= HandleSerialServerNotifications;
                    SerialServer.Dispose();
                }

                UpdateService.Instance.GotLatestVersion -= UpdateService_GotLatestVersion;
            }
            base.Dispose(disposing);
        }