第一步:定义委托
public delegate void wei(string ss);
第二步:控制UI的方法
public void get1(string ss)
{
richTextBox1.Text += ss;
}
第三步:定义线程
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
![](https://images.cnblogs.com/OutliningIndicators/ExpandedBlockStart.gif)
1 public void RecMessage() 2 { 3 //线程方法 4 控件.BeginInvoke(new wei(控制UI方法), new object[] { 参数 }); 5 }
第四步:启动线程
Thread th = new Thread(RecMessage);
th.Start();