/// <summary> /// 按钮:发送数据 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSend_Click(object sender, EventArgs e) { //if (string.IsNullOrWhiteSpace(txtSendMsg.Text)) //{ // MessageBox.Show("请先输入待发送内容"); // return; //} // 匿名发送 //udpcSend = new UdpClient(0); // 自动分配本地IPv4地址 // 实名发送 try { IPEndPoint localIpep = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 6267); // 本机IP,指定的端口号 udpcSend = new UdpClient(localIpep); string str1 = "0900400053006b88b0"; string str2 = "0900400053006b80b8"; //ArrayList str=new ArrayList(); sendStr sendStr = new sendStr(); sendStr.str1 = str1; sendStr.str2 = str2; string[] str = new string[2] { str1, str2 }; Thread thrSend = new Thread(SendMessage1); //thrSend.Start(txtSendMsg.Text); thrSend.Start(sendStr); //Thread thread1=new Thread(SendMessage); //thrSend.Start(str2); MessageBox.Show("发送成功", "信息"); } catch (Exception e1) { MessageBox.Show(this, e1.Message, "错误"); } }