Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Timer events
Message
From
22/11/2001 03:57:33
 
 
To
22/11/2001 01:05:24
General information
Forum:
Visual FoxPro
Category:
Troubleshooting
Title:
Miscellaneous
Thread ID:
00584801
Message ID:
00584828
Views:
25
This message has been marked as a message which has helped to the initial question of the thread.
Hi!

David, are you sure something else does not set it back to .T.? Try to do following:
1. Put set step on in the timer event just after this.enabled=.F. and this.Interval = 0.
2. When program stops at that point in development envuironment, debugger window should open.
3. Now see if debugger runnign any code. If timer is not really disabled - you will stop at that place again and again (and you will see that in the Call Stack debugger window).
4. When it does not fire again and again, than problem is just that somewhere in the code timer is re-enabled again before timer even is finished its work. You can track a place by following way:
Add a reference to timer.enabled property using _Screen of public variable into the whatches window. Click to left from the property to turn on the red dot - mark veriable (property) so program will stop as soon as it is changed. Note that public reference should be used because otherwise program will stop also in all places where this reference become visible/invisible that will prevent effective debugging. Then continue running program (resume its running). Program will stop at the place where property changed and you will see if it is at te end of the even or somewhere between (that cause firing again).

BTW, in older versions of VFP when you use "Enabled=.F.", all timer events are cached and when you set it to .T. and timer event code running more than Interval, timer event fire immediately again. I cannot reproduce this behavior now, but I experienced it in the past. So it is recommended to use the Interval=0 approach to disable timer for duration of its even running. So my timer even usually looks like following:

local lnOldInterval
m.lnOldInterval = this.Intervale
this.Interval = 0
... && lengthy timer event code here...
this.Interval = m.lnOldInterval


HTH.

>>>How do I stop the timer firing while in a timer event?
>>>Lets say I have a timer, tim1, on a form.
>>>If the first line of the tim1.timer() event is
>>>this.enabled= .F.
>>>shouldn't that stop the timer firing again.
>>>Yet if I debug and step through the code, the timer keeps firing.
>>>If I put
>>>this.interval= 0
>>>in the first line the debugger stops and looses its place.
>>>I'm sure I used to be able to do this somehow??
>>>
>>
>>>Also, if my timer() code takes 2 seconds to run and the interval is set to 500 milliseconds, the timer seems to re-fire whilst in the middle of the code execution. Should that be?
>>
>>It should. It is recommended therefore to reset the timer.interval to 0 at the beginning of your timer() code then re-start it after.
>
>Thanks Jess, I think i have a base class that does that. I would have thought that setting .enabled to .F. would have the same effect but it doesn't seem to in my code.
Vlad Grynchyshyn, Project Manager, MCP
vgryn@yahoo.com
ICQ #10709245
The professional level of programmer could be determined by level of stupidity of his/her bugs

It is not appropriate to say that question is "foolish". There could be only foolish answers. Everybody passed period of time when knows nothing about something.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform