Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Timer stops occassionally

Status
Not open for further replies.

GriffMG

Programmer
Mar 4, 2002
6,288
1
38
FR
I have an app, running on about 20 machines, all day everyday, all under my control and
without any human intervention.

It uses a simple timer to countdown and then runs a process. When the process finishes
the countdown starts again from a preset figure.

Once is a blue moon, the timer stops mid count, if it is coming down from, say, 200 it stops
at 184 or 93 or another seemingly random point. No more processes get fired, no errors, definitely
not in the process and nothing obvious as to why. The timer is enabled, it was counting down and
it just stops. I have a button that fires the process and resets the clock, that still works,
I can hit the escape key to exit the app.

Any ideas ?

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
What's your code?

A timer class itself does not count down, but happens after an Interval is passed, you typically disable it during it's Timer() event, so it doesn't cause any double events while still running and then reenable it at the end of the Timer event.

It's tricky, if you wait for the end of another process. I'm not surprised that could fail. But from your description it's a bit unclear, how you do that and what you really do. Solutions could involve WaitForSingleObject API call or you watch the list of current Processes or you simply RUN the process and that waits for its exit.

To be independent of that, rather RUN /N the external process and continue. That way the external process might still run at the next Timer() interval, but you could check that and skip the RUN /N in such a case.

You could also overall replace that with a task scehduler entry, but it's unclear what else you do in your always running exe.

Bye, Olaf.
 
Hi Olaf

The timer runs a little countdown on a text box which starts at (say) 200, and for each 'tick' of the timers interval (1000 ms) it deducts
1 from the text box, tests for < 1 and fires a VFP process (not an external one ) which disables the timer first, does it's various jobs and resets
the text box to 200 then enables the timer.

It is stopping between 200 and 0 after the process has finished.

Code:
	THISFORM.NEXTSCAN.VALUE = THISFORM.NEXTSCAN.VALUE -1
	IF THISFORM.NEXTSCAN.VALUE < 1
		THISFORM.TIMER1.ENABLED = .F.
		THISFORM.SCANFORREQUESTS.CLICK
		THISFORM.NEXTSCAN.VALUE = 200
		THISFORM.TIMER1.ENABLED = .T.
	ENDIF

I am using a button (thisform.scanforrequests) to run the process

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
Just for the absence of doubt 'once in a blue moon' means perhaps one timer a month will stop, out of 20 running
24/7/365 sometimes 2 and sometimes 6 months between them

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
do you think the various jobs take longer than 1000ms?

Ez Logic
Michigan
 
They all take much longer than 1000ms, some 30 secs, some longer.

That's why the timer is stopped, the jobs done and the timer reset and restarted

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
I don't know if this is relevant, but I always disable the timer at the very start of the Timer event, and re-enable it at the very end. In other words:

Code:
THISFORM.NEXTSCAN.VALUE = THISFORM.NEXTSCAN.VALUE -1
[b]THISFORM.TIMER1.ENABLED = .F.[/b]
IF THISFORM.NEXTSCAN.VALUE < 1
	THISFORM.SCANFORREQUESTS.CLICK
	THISFORM.NEXTSCAN.VALUE = 200
ENDIF
[b]THISFORM.TIMER1.ENABLED = .T.[/b]

Just a thought.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Hi Mike,

It might work, I will certainly try it, I will even move the disable to before the decrement of the timer, but I think it
is something outside of the code.

I found this with a google or two :
And he's right a little wiggle of the mouse actually appears to restart the timer



Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
And he's right a little wiggle of the mouse actually appears to restart the timer

I've never heard of that. But, assuming it's right, I wonder if moving the mouse programmatically (using the MOUSE command) would have same effect. Then again, where you would you put the code to execute the MOUSE command? In a timer?

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Exactly, perhaps I could rig up a little 'shaker' like you can get to keep a Rolex wound up and
pop the mouse on that... except there is no actual mouse, or keyboard - it's all a bit virtual
(not actually virtual) sitting in a distant data centre

B-)



Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
It doesn't happen every day, and I have another scanner on another server which checks all the other scanners
and tells me if they have stopped - after an hour or so - so it's not MC. I just wondered if anyone else had
come across it.

Could it be a memory leak type thing?

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
OK, so THISFORM.NEXTSCAN.VALUE is stuck somewhere between 200 and 0.

Then there is no current THISFORM.SCANFORREQUESTS.CLICK in the call stack, actually nothing is happening, just the timer waiting for the next timer event.
Looks odd, but that's also, what Andrew Ballew faced in his case.

I'd go with Mike Lewis idea, but maybe also do somthing else, perhaps just DOEVENTS FORCE:

Code:
THIS.ENABLED = .F.
THISFORM.NEXTSCAN.VALUE = THISFORM.NEXTSCAN.VALUE -1
IF THISFORM.NEXTSCAN.VALUE < 1
   THISFORM.SCANFORREQUESTS.CLICK
   THISFORM.NEXTSCAN.VALUE = 200
ELSE
   DOEVENTS FORCE
ENDIF
THIS.RESET()
THIS.ENABLED = .T.

Another thing, that might be very improbable is, that you seee a value <200 somewhere in the middle of a countdown, but that simply is the last number that was visually updated, and you're stick in the CLICK or whatever code executed by it. So maybe also add a THISFORM.Refresh() Or Thisform.Cls() to enforce a visual refresh of the form.

Bye, Olaf.
 
For what it's worth, I actually had the same scenario in this thread:
thread184-1712158

Try as I might, I couldn't come up with a solution. I even added a second timer to monitor the first, and restart the first timer if it quit. But alas, the second timer would also stop responding.
I finally gave up and blamed it on Windows. It was failing on a W7 32 bit (development) machine, but I haven't had it happen on XP, W7 64 bit, or any of our Server operating systems. Apps will run for months on end with the timer never failing.


-Dave Summers-
[cheers]
Even more Fox stuff at:
 
I will pop a doevents in there.

While the thisform.scanforrequests.click is running, the button is disabled, and when it finishes it is
reenabled. So while the clock counts down you can click the button to start the process early, and as the button
is enabled when the timer has stopped - it can't be in the middle of processing.

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
Hi

This is generally happening on Windows Server 2008 r2, not had the processes running on anything
else, so far as I remember, perhaps Win 2K Server.

Thanks Dave, at least I can be sure it is not just me.

I will look at your thread.

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
Dave, your description of your problem tallies exactly with mine
bar the OS, apart from them both being Windows...



Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
Because timers are interrupts, I wonder if the issue is some variable that's not declared local somewhere and thus gets stepped on. I don't see anything in the code in this thread that would be affected in such a case, but still suspicious.

I made one application that uses timers incredibly much more stable by ensuring that all variables were declared local and that mdot was used everywhere it should be.

Tamar
 
Well, you could be right, but I've not used any variables, only objects on the form

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top