Example #1
0
        public void ClosingTime(object sender, FormClosingEventArgs e)
        {
            AlreadyClosed = true;

            //Wait for the client to not be busy before closing
            while (Mainclient.IsBusy())
            {
            }

            ChatboxKeepUpdated.CancelAsync();
        }
Example #2
0
        //--------------------------------------------[ChatboxBackgroundWorker]--------------------------------------------

        private void ChatboxKeepUpdated_Start(object sender, DoWorkEventArgs e)
        {
            String NewLastMessage;

            CKUR = ChatboxKeepUpdatedResult.UNKNOWN;

            while (!ChatboxKeepUpdated.CancellationPending)
            {
                Thread.Sleep(50); //Make sure we have a moment to breathe
                while (Mainclient.IsBusy())
                {
                }                              //Wait for the client to not be busy

                try {
                    NewLastMessage = Mainclient.RequestMessage();

                    if (NewLastMessage == "NOT CONNECTED")
                    {
                        CKUR = ChatboxKeepUpdatedResult.KICKED; return;
                    }                                                                                         //If we were kicked, kick out the user.
                    if (!(NewLastMessage == LastMessage))
                    {
                        LastMessage = NewLastMessage;
                        ChatboxKeepUpdated.ReportProgress(0);
                    } //If this isn't the same as our previous message, update the cosa
                } catch (TimeoutException) {
                    CKUR = ChatboxKeepUpdatedResult.TIMEOUT; return; //If the connection times out, kick out the server.
                } catch (InvalidOperationException) {
                    CKUR = ChatboxKeepUpdatedResult.KICKED;
                    return;
                }

                Thread.Sleep(50); //Make sure we have a moment to breathe
            }

            if (CKUR == ChatboxKeepUpdatedResult.UNKNOWN)
            {
                CKUR = ChatboxKeepUpdatedResult.NORMAL_EXIT;
            }
        }
Example #3
0
        //--------------------------------------------[Form Events]--------------------------------------------

        public void Showtime(object sender, EventArgs e)
        {
            ChatBox.Text = Mainclient.WelcomeHolder;
            ChatboxKeepUpdated.RunWorkerAsync();
        }