Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Bug on timer, but not deterministic
Message
De
22/10/2003 06:44:13
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
Bug on timer, but not deterministic
Divers
Thread ID:
00840948
Message ID:
00840948
Vues:
47
Hi,

i have found a problem with timer class.

When a timer is enabled,
- it increment a internal count every Interval time is elapsed,
- decrement the count when Timer event is fired,
- reset the count when Timer.Reset() is call.

When a long time single command is executed, timer count can to become big.
If i want reset the count, i call Reset method.

But, this not reset the timer count, and a burst of timer event is fired

This code repro the problem,

BUT IT IS NOT DETERMINISTIC

Changing OS, VFP and Hardware can or cannot show the problem.

Run this, and click on Try command 2-10 times,
PUBLIC oform1

oform1=NEWOBJECT("form1")
oform1.Show
RETURN


	**************************************************
*-- Form:         form1 (c:\sviluppo\prove\schede\test timer lock.scx)
*-- ParentClass:  form
*-- BaseClass:    form
*-- Time Stamp:   10/22/03 12:22:00 PM
*
#INCLUDE "c:\sviluppo\g1\include\all.h"
*
DEFINE CLASS form1 AS form


	DataSession = 2
	DoCreate = .T.
	Caption = "Form1"
	Name = "FORM1"


	ADD OBJECT timer1 AS timer WITH ;
		Top = 11, ;
		Left = 21, ;
		Height = 23, ;
		Width = 23, ;
		Enabled = .F., ;
		Interval = 10, ;
		Name = "Timer1"


	ADD OBJECT command1 AS commandbutton WITH ;
		Top = 10, ;
		Left = 66, ;
		Height = 27, ;
		Width = 84, ;
		Caption = "TRY", ;
		Name = "Command1"


	PROCEDURE giro
		RETURN 45
	ENDPROC


	PROCEDURE Load
		CREATE CURSOR t1 (f1 I)

		FOR k=1 TO 500000
		   INSERT INTO t1  VALUES (1)
		NEXT
	ENDPROC


	PROCEDURE timer1.Timer
            this.reset
	   ? "timer",SECONDS(),this.enabled
	ENDPROC


	PROCEDURE command1.Click
		thisform.Cls
		thisform.timer1.reset
		thisform.timer1.enabled = .T.
		? "start update"
		UPDATE t1 SET f1=f1+thisform.giro()
		? "end update"
		thisform.timer1.enabled = .F.
		thisform.timer1.reset
		REPLACE ALL f1 WITH f1+thisform.giro() IN t1
		? "end REPLACE"
		* NOW burst of timer events is fired !!!
	ENDPROC


ENDDEFINE
*
*-- EndDefine: form1
**************************************************
I run this on:
-XPSP1A
-VFP8SP1
- Compaq notebook P4 2.4Ghz 512MB

Fabio
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform