示例#1
0
        private void InitConnectionThread()
        {
            ConnectionThread = new Thread(() =>
            {
                try
                {
                    client.DoConnect(remoteIEP);
                    clientIsConnected = true;
                    this.EnableUpdatingControls();
                    this.EnableGettingNewInformation();

                    /*this.Invoke(new voidDel(DisactivateConnectButton));*/
                    this.Invoke(new Action(PrepareFormToTyping));
                }
                catch (Exception exc)
                {
                    this.CloseClientConnection();
                    if (!this.RTMainChatBox.IsDisposed && !this.RTMainChatBox.Disposing &&
                        !this.ConnectButton.IsDisposed && !this.ConnectButton.Disposing)
                    {
                        this.Invoke(new Action <string, Color>(AddTextInChatBox), new object[]
                                    { "Подключение не было произведено. Возможно, сервер прекратил свою работу: " + exc.Message,
                                      Color.Red });
                        this.Invoke(new Action(ActivateConnectButton));
                    }
                }
            });
        }