public void SendMessage(object clientSocket) { // while (true) // { Socket myClientSocket = (Socket)clientSocket; Message c = DealMsg7(Encoding.Unicode.GetString(result)); //MessageBox.Show(c.type); if (c.type == "05") { //Message b = new Message(); c.msg5_Au_TS5 = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"); //this.Dispatcher.Invoke(new Action(() => { TextBox1.AppendText(c.msg2_TS2); })); this.Dispatcher.Invoke(new Action(() => { T3.AppendText(c.MMessage5(c)); })); DateTime ssmg = DateTime.Parse(c.msg5_Au_TS5).AddSeconds(1); this.Dispatcher.Invoke(new Action(() => { T5.AppendText(ssmg.ToString("yyyy/MM/dd HH:mm:ss")); })); // this.Dispatcher.Invoke(new Action(() => { TextBox1.AppendText(ssmg.Length.ToString()); })); string Cssmg; Cssmg = ssMessage(c); this.Dispatcher.Invoke(new Action(() => { T4.AppendText(Cssmg); })); Byte[] ssmg1 = new byte[1024]; ssmg1 = Encoding.ASCII.GetBytes(Cssmg); //int num1 = myClientSocket.Send(ssmg1); myClientSocket.Send(ssmg1, ssmg1.Length, 0); // Thread sendThread = new Thread(SendMessage); // sendThread.Start(myClientSocket); // myClientSocket.Close(); } if (c.type == "09") { // MessageBox.Show(c.msg1_IDc); string ssmg; ssmg = ssMessage12(c); //MessageBox.Show(ssmg); Byte[] ssmg1 = new byte[1024]; ssmg1 = Encoding.Unicode.GetBytes(ssmg); myClientSocket.Send(ssmg1, ssmg1.Length, 0); // myClientSocket.Close(); } if (c.type == "07") { string ssmg; ssmg = ssMessage8(c); //MessageBox.Show(ssmg); Byte[] ssmg1 = new byte[2048]; ssmg1 = Encoding.Unicode.GetBytes(ssmg); myClientSocket.Send(ssmg1, ssmg1.Length, 0); //myClientSocket.Close(); } // myClientSocket.Close(); //} }