线程间操作无效
时间:2014-07-01 23:20:54
收藏:0
阅读:454
第一种方法: //线程开始的时候加这么一句(把错误隐藏掉)
Control.CheckForIllegalCrossThreadCalls = false;
第二种方法:(建议采用)

private delegate void ShowDelegate(string strshow);

public void Show(string strshow)
{
if (this.txtreceive.InvokeRequired)
{
// this.txtreceive.BeginInvoke(new ShowDelegate(Show), strshow);//这个也可以
this.txtreceive.Invoke(new ShowDelegate(Show), strshow);
}
else
{
this.txtreceive.Text += strshow;
}
}
原文:http://www.cnblogs.com/mingjian/p/3816423.html
评论(0)