private void ExitApplication()
 {
     _isExit = true;
     Mw.Close();
     _notifyIcon.Dispose();
     _notifyIcon = null;
 }
        private void RemoveClient(PacketHeader header, Connection connection, string message)
        {
            currentPosition = -1;

            Dispatcher.BeginInvoke(new Action(() =>
            {
                PositionLabel.Text     = "Not in Queue...";
                CancelButton.IsEnabled = false;
                _notifyIcon.Text       = "Request for help.";
                Mw.Close();
            }));

            Connection.StopListening();
        }
 private void dispatcherTimer_Tick(object sender, EventArgs e)
 {
     try
     {
         if (Connection.Listening(ConnectionType.TCP) == true || Connection.Listening(ConnectionType.UDP) == true)
         {
             NetworkComms.SendObject("KeepAlive", serverIP, serverPort, name);
         }
     }
     catch (Exception)
     {
         Mw.Close();
         dispatcherTimer.Stop();
         _notifyIcon.BalloonTipIcon  = System.Windows.Forms.ToolTipIcon.Info;
         _notifyIcon.BalloonTipText  = "Error connecting to server. Please try again later.";
         _notifyIcon.BalloonTipTitle = "Error connecting.";
         _notifyIcon.ShowBalloonTip(3000);
         _notifyIcon.Text       = "Error connecting.";
         PositionLabel.Text     = "Not in Queue...";
         CancelButton.IsEnabled = false;
     }
 }