> > 1)    is there a function that calls the shutdown event?  
> ie,  if i'm
> > looping through my event loop,  what can i call or what 
> condition must i
> > meet to cause the application to shut down?
> 
> The AppStopEvent may be generated by a couple of possible system
> events (like pressing a hardware button or when launching another
> application).
> 
> On the other hand you just can just "break" from your event loop.
> Your application is over as soon as you leave PilotMain.
> 
> You also can enqueue an AppStopEvent, but you rarely want that.

Why would enqueueing an AppStopEvent be a bad idea ? I just worked out my
first app, and have provided a 'Done' button. When it is tapped, I have some
code in my FormHandler

eventType newEvent;
newEvent.eType = appStopEvent;
EvtAddEventToQueue(&newEvent);
eventHandled = true;

after which I exit the formHandler. It works for my very simple app (not
much more than a 'Hello World'). I had some thoughts when coding this
however. 
The SDK reference doesn't explain how EvtAddEventToQueue works with memory.
I assumed it takes a copy of the event pointed at, so I could use an auto
variable for the event information. This works, but maybe just by accident. 
On the other hand, if I have to allocate the new event, who releases it, and
when ? 
The third possibility I saw was to re-use the event that triggered my
formHandler in the first place, but I expected that event to be freed by
someone somewhere unless I did something exotic.

So the question remains: is this the right way to enqueue the AppStopEvent
(or any other event as far as I am concerned), and if it is, where are the
pitfalls ?

Sincerely,
Jan Vereecke


Reply via email to