Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Understanding Timers
Message
De
12/08/2004 17:21:28
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Titre:
Understanding Timers
Divers
Thread ID:
00932959
Message ID:
00932959
Vues:
50
I'm trying to understand exactly what the timer is doing.

I've got the following code which handles a message queue:
Add Message to queue
Set Timer Interval to 1 millisecond.
Enable Timer

** Added logging for debugging purposes.
** Function Timer
Disable Timer

Log "In Timer"

Do while there are still messages in the queue
  Log "Process the first message"
  Process the first message

  Log "Are there more messages?"
  Are there more messages?
    Log "Remove the first message"
    Remove the first message
The log is stored in a collection which writes itself out to disk when this message queue is destroyed.

I'm setting to interval to 1 to simulate what is happening on a much slower machine at a client site where the interval is set to 100.

As the code stands above the top message is being processed more than once. Approximately 10 times.

The fix is to add the following at the top of the Timer event.
** Function Timer
Has the Timer been disabled
  Return
Disable Timer
.
.
.
But without this fix, I'm trying to understand the following behavior:

I understand that between the time the Interval is set and the timer is disabled 10 Timer events have been queued up. The part that is confusing is that in some cases, the logging is skipped for a particular message, but I know the message has been processed because I see the effects of that processed message 10 times.

How is it possible to process a message and bypass the logging?
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform