DesktopApplication.CancelClosing

From Xojo Documentation

Revision as of 18:11, 23 July 2021 by Gperlman (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!
Event


DesktopApplication.CancelClosing() As Boolean

New in 2021r3

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. DesktopApplication.CancelClosing 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. DesktopWindow.CancelClosing is then called for each DesktopWindow, one after the other. If any DesktopWindow.CancelClosing 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 DesktopApplication.Closing event is called.

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