110,499
社区成员
发帖
与我相关
我的任务
分享
this.Invoke(new Action(() => this.textBox1.Text = "Lucky day!"));
this.textBox1.Invoke( new Action (() => this.textBox1.Text = "a good day!") );
delegate void SetTextCallback(string text);
private void ThreadProcSafe()
{
this.SetText("This text was set safely.");
}
delegate void DoSettext(string st);
private void SetText(string text)
{
if (this.textBox1.InvokeRequired)
{
SetTextCallback d = new SetTextCallback(SetText);
this.Invoke(d, new object[] { text });
//this.textBox1.Invoke(d, new object[] { text });
}
else
{
this.textBox1.Text = text;
}
}
#endregion
private void button1_Click(object sender, EventArgs e)
{
Thread t = new Thread(new ThreadStart(this.ThreadProcSafe));
t.Start();
}
这么说吧,上面编码中被注释掉的那行编码this.textBox1.Invoke()它和this.Invoke() 在语法上有什么区别么?