How to close the process from class code?

1k views Asked by At

I call a class form MyForm. In my class I have if-else statements. I want to close all processes. I need a command that looks like

element.close();

Example, my code:

if (_condition a_)
{
     //operations class;
}

if(_condition b_)
{
    //abort all, and close all;
}

How should I do if I am not in form? I would close all cycle by code from my class.

1

There are 1 answers

0
Tina van der Vyver On BEST ANSWER

You can start your form with the FormRun class and close it again with formRun.close(). Remember to call formRun.wait() when you want the form to remain open and wait for an action from the user.

static void openCloseForm(Args _args)
{ 
    FormRun formRun;
    Args    args = new Args();    

    args.name(formstr(MyForm));

    formRun = ClassFactory.formRunClass(args);
    formRun.init();
    formRun.run();

    if (_condition a_)
    {
        //operations class before user input;
        formRun.wait();
        //operations class after user input;
    }
    if(_condition b_)
    {
        formRun.close();
    }
}