private delegate void AddRunTimeDelegate(string strTime);
private void AddRunTime(string strTime)
{
if (textBoxTime.InvokeRequired)
{
AddRunTimeDelegate d = new AddRunTimeDelegate(AddRunTime);
textBoxTime.Invoke(d, new object[] { strTime });
}
else
{
textBoxTime.Text = strTime;
}
}
可以重复使用
public delegate void changeTextHandler(Label sender, string str);
public void changeText(Label sender , string str)
{
//Label sender;
if (sender.InvokeRequired == true)
{
changeTextHandler ct = new changeTextHandler(changeText);
sender.Invoke(ct, new object[] { sender, str });
}
else
{
sender.Text = str.ToString();
}
}
![]()
private delegate void AddRunTimeDelegate(string strTime);
private void AddRunTime(string strTime)
{
if (textBoxTime.InvokeRequired)
{
AddRunTimeDelegate d = new AddRunTimeDelegate(AddRunTime);
textBoxTime.Invoke(d, new object[] { strTime });
}
else
{
textBoxTime.Text = strTime;
}
}
View Code