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

An "Idle" method in VFP 6.0, is it possible?

Status
Not open for further replies.

Kimed

Programmer
May 25, 2005
104
LT
Hi,

I need my multy-user application to check certain database's records regularly (and possibly to react to their changing) regardless of whether the user is actively working with the app on his side or not or even if it's hanging in the background buried under other programs on desktop. Problem is, in all controls I checked so far I can only see events reacting somehow to user's actions and none that would kick in by its own volition. The closest I came up with was stuffing the check routine into MouseMove event as users are assumed to move it quite often and the check would be eventually made, but it's not good enough for me. Am I looking not thoroughly enough? Is it possible to emulate some sort of Idle method in VFP?

Thanks.
 
The easiest solution is to use a Timer control. You can arrange for this to fire at a fixed interval (which you control). When it fires, you can have it do anything you like.

If the application is idle when the timer fires, the user won't be aware of it. If the user is in the process of typing or using the mouse, they might see a small delay as the timer does its work, but only if that work is particularly intensive, such as a time-consuming query.

You can place a Timer object on your main form, or on _SCREEN. Use the Interval property to specify how often it will fire. Write code in the Timer method to perform the required action.

If you need any more information, check the VFP Help, or ask again here.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
I feel stupid. I saw the Timer hundreds times when looking at the Form Controls toolbar, but it completely evaded me when I finally had need for it. Thanks!
 
..they might see a small delay as the timer does its work, but only if that work is particularly intensive, such as a time-consuming query.

I have done this previously, when i have tried to gradually check if there is a records on my table that is on que for prcessing.
the main problem using this technique is yes the users experiences delay. and mostly they get lost in the form. sometimes when the users working on the form the cursor turns out of focus. it goes anywhere or on the next index tab.
 
Well, obviously you have to be careful that the timer task doesn't interfere with the main processing. In particular, it must be careful about switching work areas or index tags, or moving the record pointer. And it certainly shouldn't change anything in the user interface.

Apart from that, if the user is getting "lost in the form", that could point to problems in your interface design, and is not necessarily directly related to the use of a timer.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
the last position of the cursor i mean blinking cursor can be possible to determine? for that the timer can return to its last position after it executed its own procedure? because for what i have experienced while users typing lets say in an editbox for sometime after the timer executed at the backgound the blinking cursor is in other locations or controls and sometimes the form is not in focus at all. How to manage this? Thanks
 
Nothing inherent in a timer method will change focus. Therefore, it's something YOU are doing.

Yeah, you can "remember" current position at the start of your timer method and put it back. You just record _Screen.Activeform and CurrentControl, and within that control .SelStart, and put the user back there when your timer control ends. But that could actually be causing more problems. What if the user continues typing and you put them "back" to where they don't want to be any more? That would be pretty annoying too!

If your timer control is doing something that extensive, should it be part of the current exe at all? Would it make more sense as a separate EXE all on its lonesome? Perhaps running as a systray item?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top