Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
_Tally and timers
Message
De
14/03/2006 04:18:26
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
01102133
Message ID:
01104038
Vues:
22
Hi,

The interesting thing here is that the counter increments even with Autoyield = .F. (and, FWIW, removing the 'TIMEOUT .001' clause or using NOWAIT give the same results)

From the Autoyield documentation for AutoYield=.F.:
"All pending Windows events are placed in a queue, and the events in the queue are processed when DOEVENTS is issued or a wait state occurs. A wait state occurs when Visual FoxPro is waiting for input from the user. The WAIT command does not create a wait state."

The logical conclusion from this statement is that either the last sentence is untrue or that the event is NOT a windows event.

BUT there's no mention of Autoyield affecting anything *other* then windows event processing and it DOES affect the behaviour of the Timer.

And how about "Queries cannot be interrupted" - the WAIT command is part of the query! :-|

IAC you've provided an example of an undocumented risk.
Regards,
Viv



>It seems that the issue here has to do more with wait states, than any other specific situations affecting the timer. I modified your previous example as below. Some may call this cheating, however my point is that it would be pretty risky trying to predict, or otherwise disregard, the occurence and effect of wait states.
>
>
>CREATE CURSOR xTest (id N(10))
>FOR m.i = 1 TO 10
>INSERT INTO xTest (id) VALUES (m.i)
>ENDFOR
>*
>oForm = CREATEOBJECT("FORM1")
>oForm.Visible = .T.
>READ EVENTS
>
>DEFINE CLASS form1 AS form
>
>   Top = 0
>   Left = 0
>   DoCreate = .T.
>   Caption = "Form1"
>   counter = 0
>   Name = "Form1"
>
>   ADD OBJECT timer1 AS timer WITH ;
>   	Top = 24, ;
>   	Left = 36, ;
>   	Height = 37, ;
>   	Width = 61, ;
>   	Name = "Timer1"
>
>   ADD OBJECT command1 AS commandbutton WITH ;
>   	Top = 36, ;
>   	Left = 204, ;
>   	Height = 37, ;
>   	Width = 73, ;
>   	Caption = "Command1", ;
>   	Name = "Command1"
>
>   PROCEDURE timer1.Timer
>   	THIS.ENABLED = .F.
>   	THISFORM.counter = THISFORM.counter+1
>   	THIS.ENABLED = .T.
>   ENDPROC
>
>   PROCEDURE command1.Click
>      APPLICATION.AUTOYIELD = .F.
>      * Dangle around doing something for 15 seconds with the timer firing 4 times/sec
>      THISFORM.timer1.INTERVAL = 250
>      THISFORM.timer1.ENABLED = .T.
>      s = SECONDS()
>      DO WHILE SECONDS() - s < 15
>     	   *-S-*[ See Thisform.xMethod() -> You never know when a wait state may occur,
>     	   *-S-*[ which fires the timer, regardless of the AutoYield setting
>     	   SELECT id, Thisform.xMethod() AS xFire FROM xTest WHERE ID = 1 INTO CURSOR viv
>     	   * DOEVENTS
>      ENDDO
>      * Stop the Timer:
>      THISFORM.timer1.Interval = 0
>      * Enter WAIT state:
>      DO WHILE MESSAGEBOX(THISFORM.counter,1) <> 2
>      ENDDO
>      CLEAR EVENTS
>   ENDPROC
>
>   *********
>   PROCEDURE xMethod
>   *********
>   *-S-*[ WTH, does WAIT create a wait state (?)
>   WAIT WINDOW ALLTRIM(STR(Thisform.counter)) TIMEOUT .001
>   RETURN (Thisform.counter)
>
>ENDDEFINE
>
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform