Palm OS Web Application Developer's Guide: Developing and Delivering PQAs with Web Clipping

Moving to an Event-Driven Model

Before we explore any more complex examples, we must learn how to make our program event-driven. Tight loops like the one mentioned in Figure 11.1 tie up the user interface and even consume more battery power by keeping the CPU busy. We are blocking every other Palm OS function while waiting for the response from the server. Moreover, the user is forced to spend his time staring at the screen. Although Palm OS does not support multithreaded programming for users, some system libraries such as INetLib, NetLib, and the Serial Library execute in their own threads. This means that users of INetLib don t have to wait for data to arrive using a blocking call such as INetLibSockRead. Instead, the Palm OS event mechanism will notify us when the data is available in the socket. The following paragraph briefly explains how the notification works.

A Quick Introduction to the Palm OS Event Model

Palm OS maintains a queue of events that applications and libraries can use to exchange data. For example, when the user taps on the screen, the interrupt handler will identify the x and y coordinates and deliver the tap as an event to the queue. A native application can retrieve this event by calling a Palm OS function EvtGetEvent. If any events are available in the queue, EvtGetEvent will return immediately with the event. Otherwise, it will block until an event is available or until a timeout period expires.

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Trade Show, Conference, and Exhibition Support Services
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.