>I have not found a reliable way to generate a periodic event at an *exact*
>interval (and still use the OS API's).

This doesn't seem to be much different than the need by games to draw to the
screen every n ticks.  For examples, see the event loop in Reptoids.  The basic
idea is to figure out the time in ticks when the work to be done is (t =
TimGetTicks() + 2 * SysTicksPerSecond()).  When you call EvtGetEvent, ask it to
return by that time at the latest (t - TimGetTicks()).  EvtGetEvent will either
return before then with some event needing to be done, or a nilEvent at that
time.  If the event isn't a nilEvent, obviously just call EvtGetEvent again.

This technique works only for a running app.  It also just fudges it, but it
does it reasonably well!

If you look through Reptoids.c, you can basically just copy and paste the code.


-Roger Flores





To:   [EMAIL PROTECTED]
cc:    (Roger Flores/HQ/3Com)
Subject:  Re: Automated serial output




You're going to have to fudge it.  Set your app to generate the nilEvent
event with at least 2x the required frequency and check the ticks (or the
clock) to see if it is time to perform your task.  I have not found a
reliable way to generate a periodic event at an *exact* interval (and still
use the OS API's).  You could also look into using the alarm manager, but an
event every 2 seconds may not be worth the overhead.  Several developers
have posted numerous help messages on this topic in the past months, you can
search egroups for their answers.

D

-----Original Message-----
From: Stuart Norton <[EMAIL PROTECTED]>
To: Palm Developers Forum List (E-mail) <[EMAIL PROTECTED]>
Date: Wednesday, July 14, 1999 10:36 AM
Subject: Automated serial output


Hi,

Just a quickie to those in the know: How do I call a function every 2
seconds no matter what's happening in my app. I presume there's a command to
post regular events of a certain type onto the queue, that can then be
handled however I want. If so, what is this?

Thanks

Stuart Norton










Reply via email to