private void btnRun_Click(object sender, EventArgs e)
{
Thread th = new Thread(new ThreadStart(heating));
th.IsBackground = true;
th.Start();
}
int templeture;
delegate void DisplayHandler(string tempStr);
protected void heating()
{
for (int i = 0; i < 100; i++)
{
templeture = i;
string tp = i.ToString();
//this.Invoke(new DisplayHandler(Displaytemp));//这里是不带参数
this.BeginInvoke(new DisplayHandler(Displaytemp), tp);//带参数据
Thread.Sleep(1000);
}
}
protected void Displaytemp(string tempStr)
{
this.label1.Text = tempStr;// templeture.ToString();
}