Ejemplo n.º 1
0
        private void ProcessLog()
        {
            // 너무 이 작업만 할 수 없으므로 일정 작업 이상을 하면 일단 패스한다.
            int logWorkCount = 0;

            while (isProcessRunning)
            {
                System.Threading.Thread.Sleep(1);

                string msg;

                if (TextLog.GetLog(out msg))
                {
                    ++logWorkCount;

                    if (ListBoxLog.Items.Count > 512)
                    {
                        ListBoxLog.Items.Clear();
                    }

                    ListBoxLog.Items.Add(msg);
                    ListBoxLog.SelectedIndex = ListBoxLog.Items.Count - 1;
                }
                else
                {
                    break;
                }

                if (logWorkCount > 8)
                {
                    break;
                }
            }
        }
Ejemplo n.º 2
0
        void NetworkReadProcess()
        {
            while (isNetworkThreadRunning)
            {
                if (dummyClient.IsConnected() == false)
                {
                    System.Threading.Thread.Sleep(1);
                    continue;
                }

                dummyClient.Receive();

                PT_DELIVERY_CHAT recvPacket = new PT_DELIVERY_CHAT();

                recvPacket = (PT_DELIVERY_CHAT)Deserialize(dummyClient.recvBuffer, typeof(PT_DELIVERY_CHAT));

                if (dummyClient.recvBuffer.Length > 0)
                {
                    TextLog.Write($"받은 데이터: {recvPacket.Message}", LOG_LEVEL.INFO);
                }
                else
                {
                    TextLog.Write("서버와 접속 종료 !!!", LOG_LEVEL.INFO);
                }
            }
        }
Ejemplo n.º 3
0
        private void LoadMainForm(object sender, EventArgs e)
        {
            isNetworkThreadRunning = true;
            networkReadThread      = new System.Threading.Thread(this.NetworkReadProcess);
            networkReadThread.Start();
            networkSendThread = new System.Threading.Thread(this.NetworkSendProcess);
            networkSendThread.Start();

            isProcessRunning = true;
            timer            = new System.Windows.Forms.Timer();
            timer.Tick      += new EventHandler(BackGroundProcess);
            timer.Interval   = 100;
            timer.Start();

            TestConnectBtn.Enabled = false;
            DisconnectBtn.Enabled  = false;
            TestMsgBtn.Enabled     = false;

            LabelConnected.Text = string.Format("접속 클라이언트 수 : {0}", count);

            TextLog.Write("Program Starts", LOG_LEVEL.INFO);
        }