C# 跨线程设置TextBox.Text

        delegate void SetTextCallback(string text); 
public Form1()
{
InitializeComponent();
}
public void SetText(string text)
{
if (this.textBox1.InvokeRequired)
{
SetTextCallback d = new SetTextCallback(SetText);
this.Invoke(d, new object[] { text });
}
else
{
this.textBox1.Text = text;
}
}

posted on 2011-10-15 21:47  李国清  阅读(4269)  评论(0编辑  收藏  举报

导航