Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Bernard Bout
  Where is Bernard Bout?
 Brisbane
 Australia
 Bernard Bout
 To: Frank Smith
  Where is Frank Smith?
 Houston
 Texas - United States
 Frank Smith
 Tags
Subject: RE: Background program
Thread ID: 345092 Message ID: 345323 # Views: 52 # Ratings: 0
Version: Visual FoxPro 9 SP2 Category: Errors & Debugging
Date: Tuesday, May 22, 2012 3:38:09 PM         
   


> I want a program to run continuously in the background.
> Sample code is:
>
> _screen.AddObject('MyTimer','MyTimer')
> _screen.Visible = .F.
>
> DEFINE CLASS mytimer as Timer
>
> * Interval is in milliseconds.
> interval = 60000 * 3
> FUNCTION Timer
> WAIT WINDOW 'running clean ' TIMEOUT 120
> DO clean.prg
> ENDFUNC
>
> ENDDEFINE
>
> It appears that the program does not run continuously
> What did I leave out?

In addition, you have code in the Timer event:

FUNCTION Timer
	WAIT WINDOW 'running clean     ' TIMEOUT 120
   DO clean.prg
ENDFUNC 


If by any chance clean.prg does not complete its task in 60000 * 3 - 120 seconds then you have a problem with timer events "stacking up" and this will eventually bring your computer to its knees or crash the app running in the background.

The safe code to use to stop any "stacking" of timer events is:
FUNCTION Timer
        * very first line of code
        This.Enabled = .F.
	WAIT WINDOW 'running clean     ' TIMEOUT 120
        DO clean.prg
        * very last line of code
        This.Enabled = .T.
ENDFUNC 




Bernard

** If you see someone without a smile, give em one of yours :) **
My Blog

ENTIRE THREAD

Background program Posted by Frank Smith @ 5/18/2012 2:36:21 AM
RE: Background program Posted by onytoo @ 5/18/2012 10:34:08 AM
RE: Background program Posted by Stefan Wuebbe @ 5/18/2012 10:39:42 AM
RE: Background program Posted by Frank Smith @ 5/18/2012 4:15:33 PM
RE: Background program Posted by Bernard Bout @ 5/22/2012 3:38:09 PM