在我的Main方法中,我UpdateDialog根据用户是否按下按钮来实例化其中的类,我需要function1()从Main. 这是代码:
public partial class Main : Form
{
public void function1()
{
doing_stuff_here();
}
private void button1_Click(Object sender, EventArgs e)
{
var update = new UpdateDialog();
update.ShowDialog();
}
}
public partial class UpdateDialog : Form
{
private void button2_Click(object sender, EventArgs e)
{
//call here function1() from Main
}
}
我应该怎么做才能function1()从Main部分类内部调用UpdateDialog?
LE:虽然 Styxxy 建议的方法看起来是对的,但它在我的应用程序中效果不佳,cross-thread invalid operation因此我最终使用了delegate workaroundCuong Le 建议的方法。