Application.CancelClose

From Xojo Documentation

Event


Application.CancelClose() As Boolean

Supported for all project types and targets.

This event occurs first when the application is about to terminate, e.g. if you used the Quit command or if the user chose Quit from the menu. Return True to cause the termination to stop.

Notes

The Termination Process in GUI Applications

This is the order in which events are called when a GUI application initiates a termination process, i.e. when it quits:

  1. Application.CancelClose is called first. If, for any reason, you want to stop the termination process or interact with the user (use a modal window in such a case) to confirm, you should do it in this event. If you return True, the termination process will be stopped immediately.
  2. Window.CancelClose is then called for each Window, one after the other. If any Window.CancelClose returns True, the termination process will be stopped.
  3. Windows are all closed, one after the other. In the process, each Window.Close event is called but you can no longer interrupt the termination process.
  4. If you use asynchronous object like Threads, Timers or sockets, they are terminated by the runtime environment then destroyed even if the runtime did not or could not stop them. If such objects are subclasses and have a Destructor event, it will be called.
  5. The Application.Close event is called.

Note that some objects can be destroyed (so their Destructor event called) after the Application.Close event has been invoked.