David,

The "sleep" just freezes that particular thread, which sometimes can cause 
unexpected drag on an app, so I prefer the version which uses timers like below:

Sub CheckForState()
      ' code activity goes here...
      startTimer 5000, "CheckForState"
 End Sub 'ChackForState.

-----Original Message-----
From: David [mailto:trailerda...@hotmail.com] 
Sent: Thursday, January 22, 2015 6:06 AM
To: gw-scripting@gwmicro.com
Subject: Think I could need a bit of help...

Scripters,
In one of my projects, I need some routine to check a certain state of 
things, with given intervals. This should be done in the background, 
with as little interference with the user's activity, as possible. Let's 
for instance say, you want to check if a file has been updated, and you 
want to do that every 5 minutes, all through the day.

OK, I have one idea, but wanted to know if the WE API gives a better 
solution, and if so, could someone please point me to some code or the 
like, that illustrates how to implement. Here is the idea I have, but 
not sure if it is all that waterproof, or if it holds any chance of 
malfunctioning the app.

Sub CheckForState()
     Sleep 5000     'Let's just give it five seconds interval.
     ' code activity goes here...
     CheckForState()
End Sub 'ChackForState.

In other words, a simple, recursive sub, that will keep running all till 
the app closes. Yet, what if I need to end it from running, at any given 
state throughout the app execution? Like I said, not sure if this is the 
best and most smooth way to handle this task, so if anyone has a better 
idea, I am all ears.

Thanks,

-- 
David

Reply via email to