Async call back後show另一form會當掉
源碼如下:
public void p_rod052_back(object[] oret1)
{
string repn = "rod052";
cr070v.Form1 temp = new cr070v.Form1();
temp.repn = repn;
temp.MdiParent = this.MdiParent;
temp.WindowState = FormWindowState.Maximized;
temp.Show();
}
異步呼叫與Form的show是有沖突.
以上述例子來看,解決方法:
1. 在public void p_rod052_back(object[] oret1)上面加一行程式:
public delegate void ShowForm();//定義一個委託
2. 原public void p_rod052_back(object[] oret1)改為:
{
ShowForm call = delegate()
{
string repn = "rod052";
cr070v.Form1 temp = new cr070v.Form1();
temp.repn = repn;
temp.MdiParent = this.MdiParent;
temp.WindowState = FormWindowState.Maximized;
temp.Show();
}
this.Invoke(call);
}