Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Are Timers useful?
Message
From
24/09/2001 09:51:37
Bruce Gordon
Wicks Broadcast Solutions, Llc
Vienna, Virginia, United States
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Other
Title:
Are Timers useful?
Miscellaneous
Thread ID:
00559941
Message ID:
00559941
Views:
58
How can I get a timer on a form to receive timer events when other code in the form is running? DoEvents allows me to interrupt that code by pressing a button, but the timer events are not received until the end of the process.

I am using VFP7. The test form has 2 buttons: Do Stuff and Message. Message just pops up a messagebox. The code for Do Stuff is shown below. The timer activated by Do Stuff (.Timer1) has, as its timer method, code to disable the timer, pop up a messagebox, and enable the timer again. Various labels on the form show the progress of the Do Stuff loop and how long it takes.
* Do Stuff Click Code
WITH ThisForm
	LOCAL i, j, ltStart
	.Timer1.interval = 1500
	.Timer1.enabled = .T.
	.lblNum.Caption = '0'
	.lblSec.Caption = '0'
	ltStart = SECONDS()
	j = 0
	FOR i = 1 TO 200000
		DOEVENTS
		j = j+1
		.lblNum.Caption = ALLTRIM(STR(j))
	ENDFOR
	.lblSec.Caption = ALLTRIM(STR(SECONDS() - ltStart))
EndWith
Regardless of how I fiddle with AutoYield and use DoEvents, I cannot get the timer events to be sent to the timer while the loop is processing. However, with the code above, the Message button will fire, and, while its MessageBox is up, the loop is suspended, as .lblNum is not incremented.

Any help greatly appreciated.

Thanks,
Bruce Gordon
Next
Reply
Map
View

Click here to load this message in the networking platform