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); } } }
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); }