定义个委托:
1delegate void SetTextCallback(string text);
2
2
线程执行的代码:
1public void SendAlarm(object state)
2 {
3 string xmlString = XmlStructor.GetTFMXml(ct);
4 if (this.textBox1.InvokeRequired)
5 {
6 SetTextCallback s = new SetTextCallback(setText);
7 this.Invoke(s,xmlString);
8 }
9 msgclass.Send(xmlString);
10 }
操作控件:2 {
3 string xmlString = XmlStructor.GetTFMXml(ct);
4 if (this.textBox1.InvokeRequired)
5 {
6 SetTextCallback s = new SetTextCallback(setText);
7 this.Invoke(s,xmlString);
8 }
9 msgclass.Send(xmlString);
10 }
1/// <summary>
2 /// 测试
3 /// </summary>
4 /// <param name="x"></param>
5 public void setText(string x)
6 {
7 textBox1.Text += (x + "\r\n\r\n\r\n\r\n");
8 }
2 /// 测试
3 /// </summary>
4 /// <param name="x"></param>
5 public void setText(string x)
6 {
7 textBox1.Text += (x + "\r\n\r\n\r\n\r\n");
8 }