标签:
譬如设置控件的文本,
private void SetControlText2(Control c, string text)
{
if (c.InvokeRequired)
{
this.Invoke(new MethodInvoker(delegate() { SetControlText2(c, text); }), c, text);
}
else
{
c.Text = text; ;
}
}
上面这是简易的写法,要写成下面这种也可以;
private delegate void SetControlTextCallBack(Control c, string text);
private void SetControlText(Control c,string text)
{
if (c.InvokeRequired)
{
this.Invoke(new SetControlTextCallBack(SetControlText), c,text);
}
else
{
c.Text = text; ;
// btnTest.Text =bool( o);
}
}
标签:
原文地址:http://www.cnblogs.com/birds-zhu/p/5621522.html