Ejemplo n.º 1
0
        protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
        {
            Mubox.Control.Input.KeyboardInputHook.KeyboardInputReceived -= KeyboardInputHook_KeyboardInputReceived;
            Mubox.Control.Input.MouseInputHook.MouseInputReceived       -= MouseInputHook_MouseInputReceived;

            Mubox.Control.Input.KeyboardInputHook.Stop();
            Mubox.Control.Input.MouseInputHook.Stop();

            Mubox.Control.Network.Server.Stop();

            ClientBase[] clients = GetCachedClients();
            this.Dispatcher.Invoke((Action) delegate()
            {
                ClientWindowProvider.Clear();
            });

            foreach (ClientBase client in clients)
            {
                NetworkClient networkClient = client as NetworkClient;
                if (networkClient != null)
                {
                    try
                    {
                        networkClient.Detach();
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine(ex.Message);
                        Debug.WriteLine(ex.StackTrace);
                    }
                }
            }

            base.OnClosing(e);
        }