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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple Timers

Status
Not open for further replies.
Feb 14, 2000
425
US
I have a situation where the only solution I can come up with would require me to put two timers on a form. I know I CAN do it, I am just not sure for some reason if it would be wise to do this. Don't know why, just some little voice in my head saying "might not be smart". So I am throwing this out there to see if there is any one that has done this in the past and if there is anything to watch out for.

Steve Bowman
Independent Technology, Inc.
CA, USA
 
Steve,
Yes, I have, but only when the timers control two independant events. I don't know if your solution needs to have them somehow "interact" with each other, in which case, yeah... I feel like there could be a "Time Warp" involved, but otherewise, no I don't see why not.


Best Regards,
Scott

"Everything should be made as simple as possible, and no simpler."[hammer]
 
to be clear, the timers will process independent logic. They will use the same tables shared but they will not "interact"

I have process 1 that will create records

And process 2 will print out the data after 10 records are created or until a set timeout limit is reached where it will print what ever number of records I have

Thank you for your reply



Steve Bowman
Independent Technology, Inc.
CA, USA
 
Steve,

I've been working on a project that requires two timers on a form and haven't had any problems.

Mike Reigler
Melange Computer Services, Inc
 
Steve,
The only caveate I see to your situation is, if there is a "timing" issue when the print starts. That is easily overcome however by just ensuring a way of marking records have been printed at the time they are, so that if it gets "missed" by a timing error, it is picked up automatically in the next timing cycle/record limit.



Best Regards,
Scott

"Everything should be made as simple as possible, and no simpler."[hammer]
 

Steve,

I agree with Mike Reigler. I have several forms with multiple timers. It's generally OK, even if Timer B fires while Timer A's Timer event is in progress.

What you don't want is for a given timer's Timer event to fire while that same event is in progress (in other words, you start processing the code in the Timer event, but before you finish, the timer fires again).

To avoid that, it's good practice always to disable a timer at the start of its own Timer event, and re-enable it at the end. I typically do something like this:

Code:
* Timer event
LOCAL lnSaveInterval
lnSaveInterval = THIS.Interval
THIS.Interval = 0

* Do whatever you need to do
THIS.Interval = lnSaveInterval

I suppose you could also do it just by toggling the Enabled property, but the above is how I have always done it.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Thank you all for the very sound advice, I will start coding feeling much better about the situation.

Steve Bowman
Independent Technology, Inc.
CA, USA
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top