GEOS SDK TechDocs
|
|
1.2 Launching an Application
|
1.4 Saving and Restoring State
MSG_GEN_PROCESS_CLOSE_APPLICATION, MSG_GEN_PROCESS_CLOSE_ENGINE, MSG_GEN_PROCESS_CLOSE_CUSTOM, MSG_META_QUIT
Just as loading an application is handled almost entirely by the system and GEOS classes, application shutdown is also fairly automatic. If the application intercepted
MSG_GEN_PROCESS_OPEN_APPLICATION
for its own purposes on startup, it likely has to do a little cleanup; otherwise, it won't have to worry about shutting down. (See Saving and Restoring State
for special information on using this message.)
Any object in the system may cause an application to shut down. Usually, shutdown occurs either when the system is being exited (when a user exits to DOS, for example) or when the user has closed the application. Therefore, the usual source of the shutdown directive is the User Interface.
An application begins shutting down when either its Process object or its Application object receives a
MSG_META_DETACH
. If you want to cause a shutdown manually, you should send
MSG_META_QUIT
to the application's GenApplication object; this will execute some default functions and then send the appropriate
MSG_META_DETACH
. Essentially, the same detach and destruction mechanisms used for any object are used for the entire application. The object receiving
MSG_META_DETACH
passes the message along to all of its children and to all the objects on its active list. (If a
MSG_META_DETACH
is used without
MSG_META_QUIT
, the application will create a state file.)
When they have all acknowledged the detach, the application acknowledges the detach and sets itself unusable. It automatically flushes its message queues before shutting down to avoid synchronization problems. You should not subclass the
MSG_META_DETACH
handler unless you have special needs for cleaning up or sending special detach messages to other objects or geodes. If you do subclass it, you must call the superclass at the end of your handler. Otherwise, the application will not finish detaching (see the GEOS Programming chapter).
Instead of intercepting
MSG_META_DETACH
, though, the application may intercept the mode-specific message it will also receive. Depending on the mode in which it was launched, the application will receive (via the Process object) either
MSG_GEN_PROCESS_CLOSE_APPLICATION
(for application mode) or
MSG_GEN_PROCESS_CLOSE_ENGINE
(for engine mode). There is no special shutdown message for shutting down to a state file; instead,
MSG_GEN_PROCESS_CLOSE_APPLICATION
is used.
When the system shuts down or task-switches, a different type of shutdown occurs. Applications (or other objects interested in this event) must register for notification on the notification list GCNSLT_SHUTDOWN_CONTROL (notification lists are described in the General Change Notification chapter). When the system shuts down or task-switches, the object will then receive a MSG_META_CONFIRM_SHUTDOWN
, at which time the object must call
SysShutdown()
.
GEOS SDK TechDocs
|
|
1.2 Launching an Application
|
1.4 Saving and Restoring State