??????У???????壬?????????????????飬????ν???????????дC#????????????C#????????????????????????????в?????ɡ?
????1??????????????У?
???????????  delegate ?????????  ?????(????)
??????????????????????????????????????д??е?????????????????????д??
????delegate void set_Text(string s);//???????
????private void set_lableText(string s)
????{
????label1.Text = s;
????}
???????????????з??????????????з???????????д??????????????д????????
????2?????塢????????
????set_Text Set_Text; //???????
????Set_Text = new set_Text(set_lableText); //????????
?????????????????
????3????????????????У???????????????????????д??
private void button1_Click(object sender?? EventArgs e)
{
thread1 = new Thread(new ThreadStart(run));
thread1.Start();
}
private void run()
{
for (int i = 0; i < 101; i++)
{
label1.Invoke(Set_Text?? new object[] { i.ToString() }); //?????????У??????lable1???
Thread.Sleep(1000); //????????????λ??ms
}
}
???????????????£???д??????????????Щ???????!
?????????????????? label1.text=i.toString();?????label1.Invoke(Set_Text?? newobject[] { i.ToString() });
????????????label1??text??????????????????
??????????????????????????????????