110,499
社区成员
发帖
与我相关
我的任务
分享
using System.Threading;
public delegate void MyInvoke(string str);
private void btnStartThread_Click(object sender, EventArgs e)
{
Thread thread = new Thread(new ThreadStart(DoWord));
thread.Start();
}
public void DoWord()
{
MyInvoke mi = new MyInvoke(SetTxt);
BeginInvoke(mi,new object[]{"abc"});
}
public void SetTxt(string str)
{
txtReceive.Text += str + System.Environment.NewLine;
}
if (this.InvokeRequired)
{
this.Invoke((System.Threading.ThreadStart)(() => this.doSomeThing()));
}
else
{
this.doSomeThing();
}