线程异步调用方法
private void button1_Click(object sender, EventArgs e)
{
System.Threading.Thread thread = new System.Threading.Thread(() =>
{
setText("TTTT");
});
thread.IsBackground = true;
thread.Start();
}
private delegate void setRichTexBox(string s);
public void setText(string txt)
{
if (this.textBox1.InvokeRequired)//等待异步
{
setRichTexBox fc = new setRichTexBox(Set);
this.Invoke(fc, new object[] { txt });
}
else
{
this.textBox1.AppendText(txt);
}
}
private void Set(string txt)
{
textBox1.AppendText(txt);
}

浙公网安备 33010602011771号