Front-end termination

The OPTIONS CLOSE APPLICATION instruction defines the callback function in case of front-end termination.

Syntax

OPTIONS ON CLOSE APPLICATION CALL function
  1. function is the name of a function with no parameters or return value.

Usage

The OPTIONS ON CLOSE APPLICATION CALL function can be used to execute specific code when the front-end sends an application close event. This event can occur in the following cases:
  • With the Genero Desktop Client (GDC) in direct mode:
    • When the specific application connection in the GDC control panel is closed.
    • When the GDC front-end program is closed. This occurs also when the OS user sessions is ended, or when workstation OS is shutdown.
  • With the Genero Application Server (GAS) and a web browser, after the timeout defined by the USER_AGENT .xcf configuration parameter:
    • When the browser tab containing application forms is closed.
    • When the browser is closed. This occurs also when the OS user sessions is ended, or when workstation OS is shutdown.
    • When the Genero Application Server is shutdown.

Before stopping, the front-end sends an internal event that is trapped by the runtime system. When a callback function is specified with this program option command, the application code that was executing is canceled, and the callback function is executed before the program stops.

Use the OPTIONS ON CLOSE APPLICATION CALL function instruction with care, and do not execute complex code in the callback function. The code is expected to contain only simple and short cleanup operations; any interactive instruction is avoided.

Important: A front-end program crash or network failure is not detected and cannot be handled by the ON CLOSE APPLICATION option.

Example

MAIN
    OPTIONS ON CLOSE APPLICATION CALL end_app
    MENU "test"
        COMMAND "quit" EXIT MENU
    END MENU
END MAIN

FUNCTION end_app()
    DISPLAY "Program terminated by front-end..."
END FUNCTION