111,125
社区成员
发帖
与我相关
我的任务
分享
public partial class Form1 : Form
{
public delegate string Set(int i);
Set s;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Thread t1 = new Thread(new ThreadStart(run1));
s = new Set(SetControl);
t1.Start();
}
public void run1()
{
for (int i = 0; i < 100; i++)
{
Thread.Sleep(100);
this.Invoke(s, i); //如何得到返回
}
}
public string SetControl(int i)
{
this.label1.Text = i.ToString();
return i.ToString(); //返回了i
}
}