Command to terminate screen application?

Options

Hi,

What is the command to terminate the screen, from within the screen code (in case, say, a fatal error occurs and you want to force it to close down)?

So far I've tried, unsuccessfully:

Dispose(); //Doesn't do the job
System.Windows.Forms.Application.Exit(); //Closes the whole flexpendant!
Parent.Controls.Remove(this); //doesn't do the job
DestroyWindow(); //Can't get Windows API to work (unknown)

Thanks.

Michael Siminski
Technical Support Engineer
Robotics Product & Systems Service
Manufacturing Automation, Automation Technologies (ATMA)
ABB Australia
Email: michael.siminski @ au.abb.com

Comments

  • RussD
    Options

    You should use a

    Try...Catch block

    around "risky" code to catch the error you are getting so that you can respond in some sort of controlled way.

    If you catch the error and don't allow it to be escalated to the level of an unhandled exception (which must close the application), then you probably wouldn't need to force it to be closed.

     

    Russell Drown
  • msiminsk
    Options

    Thanks for the reply.

    In certain circumstances it may still be desirable to force the screen to close.

    If, for example, the screen relies on the robot system being set up a certain way for a key functionality, but this is found not to be the case, then the screen may not be of much use and it might be desirable to close it down. If, during start-up, the screen detects that the system is not set up correctly, it might be desirable to display a message to the user explaining what's wrong and that the screen cannot function properly. After that, it might be desirable to close the screen down to prevent a dis-functional screen being left open and so as not to confuse the user.

    Is there a command that will close the screen, if so desired?

    Thanks.

    Michael Siminski
    Technical Support Engineer
    Robotics Product & Systems Service
    Manufacturing Automation, Automation Technologies (ATMA)
    ABB Australia
    Email: michael.siminski @ au.abb.com
  • RussD
    Options

    I don't think this is possible, because I believe the TAF has to call the de-activate and un-install methods on applications to close them.

    Your best best would be to check for your requirements early during initialization and disable all functionality or display an error dialog at the first sign of trouble.

    Russell Drown
  • msiminsk
    Options

    Could this be requested as a feature in a future version?

    Thanks.

    Michael Siminski
    Technical Support Engineer
    Robotics Product & Systems Service
    Manufacturing Automation, Automation Technologies (ATMA)
    ABB Australia
    Email: michael.siminski @ au.abb.com