Event Loop


This picture illustrates control flow in a typical application. An application performs a full startup when it receives the launch code sysAppLaunchCmdNormal Launch. It begins with a startup routine, then goes into an event loop, and finally exits with a stop routine.

In the event loop, the application fetches events from the queue and dispatches them, taking advantage of the default system functionality as appropriate. While in the loop, the application continuously checks for events in the event queue.

If there are events in the queue, the application has to process them as determined in the event loop. As a rule, the events are passed on to the system, which knows how to handle them. For example, the system knows how to respond to pen taps on forms or menus. The application typically remains in the event loop until the system tells it to shut itself down by sending an appStopEvent through the event queue.