Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Stefan Wuebbe
  Where is Stefan Wuebbe?
 Stefan Wuebbe
 To: Frank Smith
  Where is Frank Smith?
 Texas - United States
 Frank Smith
Subject: RE: Background program
Thread ID: 345092 Message ID: 345102 # Views: 76 # Ratings: 0
Version: Visual FoxPro 9 SP2 Category: Errors & Debugging
Date: Friday, May 18, 2012 10:39:42 AM         

> 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
> WAIT WINDOW 'running clean ' TIMEOUT 120
> DO clean.prg
> It appears that the program does not run continuously
> What did I leave out?

There is no "Read Events" in the code, does it help to add one?

So that somewhere you'd probably also have a "Clear Events" counterpart that would need to run when the invisible EXE is meant to exit.
In addition, you would avoid Windows log-out / shutdown issues if you add a line like "On Shutdown quit" at the top of the main.prg

FWIW, the "_screen.Visible = .F." would be superfluous if you'd have a config.FPW file included in the project containing a line "Screen=Off" (and a second line "Resource=Off" would prevent foxuser.* creation when the EXE is starting).

In turn, if you do not have "Screen=Off" in a config.fpw, you'd see the _screen appearing at early start-up and then immediately disappear when "_screen.Visible = .F." runs because the first custom-code lines run relatively late at run-time, so that you'd get a noticeable flicker effect.



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