In the init method of an intermediate form I'm trying to open a new form and close current one. Below code opens the second form however with an error message "cannot call close without detach or wait" although I tried adding element.detach() but error persists
void Init()
{
FormRun formRun;
Args args = new Args();
super();
element.close();//can't close
args.name(formstr(Form1));
formRun = ClassFactory.formRunClass(args);
formRun.init();
formRun.run();
formRun.detach();
}