hi,
I am using the below function to close the existing form and open a new form. I have a function running as thread which shud run in background always. when i call the below function from my function in thread, the thread is not doing its work after that. May be the thread is aborting. How to resolve this. Thanks.
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);
if (Application.OpenForms.Count > 0)
{
MyContext.curMain.Invoke(new Action(MyContext.curMain.Dispose));
}
}
MyContext.curMain = main;
MyContext.curMain.FormClosed += new FormClosedEventHandler(main_FormClosed);
MyContext.curMain.ShowDialog();
}
}