이 기능을 사용하여 기존 양식을 닫고 새 양식을 엽니 다.C# Windows 응용 프로그램에서 열린 양식 찾기
exixting 양식이 없으면 오류가 발생합니다.
오류 :
대상 :은 System.Object MarshaledInvoke (System.Windows.Forms.Control, System.Delegate,은 System.Object []을, 부울)
메시지 : 호출 또는 BeginInvoke는에 호출 할 수 없습니다 윈도우 핸들이 생성 될 때까지 컨트롤.
스택 : System.Windows.Forms.Control.MarshaledInvoke에서
가되도록 않도록 형태를 닫기 전에 열려 임의의 형태를 확인하기 위해 필요한 (컨트롤 호출자 위임 방법, [] args를 부울 동기 개체) 오류. 방법?
static public void NewMainForm(Form main, bool ClosePreviousMain)
{
if (main != null)
{
Global.ActiveForm = main.Text;
if (ClosePreviousMain & MyContext.curMain != null)
{
MyContext.curMain.FormClosed -= new FormClosedEventHandler(main_FormClosed);
//Need to check for any form active and then close the form.
MyContext.curMain.Invoke(new Action(MyContext.curMain.Dispose));
}
MyContext.curMain = main;
MyContext.curMain.FormClosed += new FormClosedEventHandler(main_FormClosed);
MyContext.curMain.ShowDialog();
}
}