Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
_Tally and timers
Message
From
13/03/2006 10:44:12
 
 
To
13/03/2006 06:18:39
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01102133
Message ID:
01103750
Views:
19
Hi,

>
I think that a timer may fire between each line of code, provided autoyield is TRUE. (Maybe a timer is set up in such a way that it uses a windows event)
I've had the case where a grid refesh used some dynamic* and the dynamic* used functions to return eg the forecolour.
The timer interrupted those functions
>

OK. Here's another test:
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 = .T.
		* 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
			  SELECT ID FROM cTable 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
	ENDPROC
ENDDEFINE
With Autoyield = .F. the Timer code never executes (either in the main loop or in the subseqent wait state) regardless of the inclusion of DOEVENTS - the interrupt is effectively discarded.

With Autoyield = .T. and DOEVENTS included the timer code executes in the main loop as expected. But with no DOEVENTS the timer event is queued and only executes in the wait state - the .Counter will initially be 0, hitting OK at intervals will show the previously queued events being consumed.

So the grey area is 'Can the timer code EVER execute with AUTOYIELD = .T. unless there's a wait state' ? My hunch would be 'No' but I wouldn't bet the ranch on it. OTOH, I'd be interested to see someone positively demonstrate the opposite :-}
It would also be interesting to see how many interrupts would be queued!

Regards,
Viv
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform