我的目标是,在“Dummy”函数中,我可以更改线程启动的表单的标签等控件……怎么做……请不要提出完全不同的策略或创建工人阶级等。 ..如果可以的话,修改它
Thread pt= new Thread(new ParameterizedThreadStart(Dummy2));
private void button1_Click(object sender, EventArgs e)
{
pt = new Thread(new ParameterizedThreadStart(Dummy2));
pt.IsBackground = true;
pt.Start( this );
}
public static void Dummy(........)
{
/*
what i want to do here is to access the controls on my form form where the
tread was initiated and change them directly
*/
}
private void button2_Click(object sender, EventArgs e)
{
if (t.IsAlive)
label1.Text = "Running";
else
label1.Text = "Dead";
}
private void button3_Click(object sender, EventArgs e)
{
pt.Abort();
}
}
}
我的计划是我可以在“虚拟”功能中做到这一点
Dummy( object p)
{
p.label1.Text = " New Text " ;
}