Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Timer events
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Problèmes
Titre:
Divers
Thread ID:
00584801
Message ID:
00585091
Vues:
35
>>whoops, that's
>>
>>this.enabled=.F.
>
>I think there is a problem here, try this code
>
>
>LOCAL oFrm AS Form, oTim AS Timer
>
>oFrm = CREATEOBJECT("tForm")
>oFrm.AddObject("tTim", "tTimer")
>
>oFrm.show()
>READ EVENTS
>
>DEFINE CLASS tForm AS Form
>	Caption= "Test Timer"
>	Name= "Form1"
>	Height= 80
>	Width= 180
>	
>	ADD OBJECT command1 AS CommandButton
>	
>	command1.caption = "Start"
>	
>	PROCEDURE command1.click
>		thisform.tTim.interval = 1
>	ENDPROC
>
>ENDDEFINE
>
>DEFINE CLASS tTimer AS Timer
>	Name = "Timer"
>
>	PROCEDURE Timer
>		this.Interval = 0
>		ACTIVATE SCREEN _SCREEN
>		? DATE()
>		ACTIVATE SCREEN this
>	ENDPROC
>ENDDEFINE
>
>
>As is my understanding, this would print 1 DATE() to the _SCREEN for every click of the start button.
>However it prints about 8-10
>
>Seems wrong to me, though it could be my code, so feel free to correct me if im wrong

I think this is due to the time taken from setting interval to 1, which starts the timer events going, & resetting it to 0, which stops the events. In between all timer events are buffered, so if for whatever reason there is an 8 msec delay between the setting & resetting, then you will get 8 prints. Try printing seconds() directly after setting interval to 1 & resetting to 0, the number of prints should correspond to the difference in milliseconds on setting to 1 & the first print. (Because of other delays eg processing time beween lines of code, the correspondence is not exact, but in the right ball park)

On my sluggish PC, the delay was 5msec-70msec so I got between 5 & 70 prints.
Len Speed
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform