Ejemplo n.º 1
0
        public FormChat(GetLoginInfo getLogin)
        {
            InitializeComponent();

            this.getLogin  = getLogin;
            username       = getLogin.login;
            dataController = new DataController();

            try
            {
                this.connection = new CircleConnection(this, this.dataController, getLogin.login, getLogin.backComName, getLogin.forwardComName);
            }
            catch (Exception)
            {
                MessageBox.Show("Невозможно открыть заданные COM порты");
                Application.Exit();
            }
            //таймер для обработки маркера
            RWTimer          = new Timer();
            RWTimer.Interval = 250;
            RWTimer.Tick    += RWTick;
            RWTimer.Start();
            //таймер для отображения кнопки закрытия
            SwitchConnBtnTimer          = new Timer();
            SwitchConnBtnTimer.Interval = 1250;
            SwitchConnBtnTimer.Tick    += SwitchConnBtnTick;
        }
Ejemplo n.º 2
0
        private void CloseConnectionInTick(bool showConnectionLost)
        {
            DateTime time = new DateTime(DateTime.Now.Ticks);

            while (!connection.CanClose() && (DateTime.Now - time).TotalMilliseconds < 2500)
            {
                ;                                                                             // нечего передавать и время работы
            }
            connection.Close();
            connection = new CircleConnection(this, this.dataController, getLogin.login, getLogin.backComName, getLogin.forwardComName);
            this.Invoke((Action <bool>)(delegate(bool idle)
            {
                onlineUsersList.Items.Clear();
                if (showConnectionLost)
                {
                    LogBox.AppendText("# Соединение потеряно" + Environment.NewLine);
                }
            }), true);
        }