Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Timer events
Message
From
22/11/2001 22:58:36
 
 
General information
Forum:
Visual FoxPro
Category:
Troubleshooting
Title:
Miscellaneous
Thread ID:
00584801
Message ID:
00585043
Views:
34
well im running vfp7 - and something strange is happening. ill need to work at it when i get a chance, but what happens is that
in the timer event i have
this.interval=0
this.enabled=0
set step on
line1
line2
line3
..

now when the debugger comes up it stops fine on line1. nothing happens, as i expect. if i then set to the next line2 i'm whisked out of the timer event and back to read events for the form. it doesn't matter what line1, line2 etc are.

anyway let me look into this more closely.

thanks for your help
>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.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform