Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Turning off a timer control
Message
From
14/04/2011 08:20:40
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01507105
Message ID:
01507287
Views:
184
>That's what I thought.
>
>Mmmmmm....
>
>Looks like a have a bug in my code then, it seems to be still firing.
>
>Thanks guys, will look deeper

In one app, I've found that I need code like the following in the Timer method to ensure that the timer fires only once:
	IF NOT This.Enabled
		* This might happen if the timer fired twice before we disabled it.
		This.oDLmainRef.AddToLogFile("Timer is disabled, getting out of timer method.")
		RETURN
	ELSE 
		THIS.ENABLED = .F.
		LOCAL nTimerInterval
		nTimerInterval = This.Interval
		This.Interval = 0
		This.oDLmainRef.AddToLogFile("In Timer event of response timer")
	ENDIF 
The key point is that just inside the method, I check whether it's already disabled and get out if it is. Adding this code solved some ugly problems for me, and I do now and them see the "Timer is disable" line in the log I'm creating. (This is a COM object, so the log is critical.)

Tamar
Previous
Reply
Map
View

Click here to load this message in the networking platform