Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to execute a background form
Message
From
06/07/2001 04:25:44
 
 
To
05/07/2001 18:48:02
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00527251
Message ID:
00527341
Views:
27
Hi!

It is not call of a form in the timer event. It is organizing of the background process using a timer.

Create a form and make it modeless, not modal. Put a timer control in it. Specify interval 100ms for start, later you will require to tune this value for the best balansing between background process speed and quility of accessing by user other resources of application, like menus or other forms. In the timer event put the processing code, wrapped into the switchng ff timer:

* timer event
local lnOldInterval
m.lnOldInterval = this.Interval
this.Interval = 0
...
this.Interval = m.lnOldInterval

Do not use Enabled property of the Timer control to switch off timer in the Timer event. With that approach all pending timer events will fire at once and will be kept in the events queue. This is dangerous becaus if your background process will take more time than 100ms, this queue will grow quickly taking valuable resources and giving user no chanse to do something else but wait while process finished.

Instead of '...' put your background process code that is aware of the previous runs of the timer event. In other words, you require some object or variables or something like that that holds a state of the background process, so next time timer event called you can check the state of previous run and know how to continue. For example, when you process some table content, process one record at one call of the timer event. In such case state will be record pointer in that table. When processing finished, set INterval property of timer to 0 to switch it off. To start process again, clear the data about state of the process and set Interval of the timer to the optimal value again.

HTH.

>Hello.
>
>I want to call a form from a timer event, but I want it to be executed as background form so I can access other menus or forms while the background process is running.
>
>How can i do this?
>
>Thanks.
>
>Juan Carlos
Vlad Grynchyshyn, Project Manager, MCP
vgryn@yahoo.com
ICQ #10709245
The professional level of programmer could be determined by level of stupidity of his/her bugs

It is not appropriate to say that question is "foolish". There could be only foolish answers. Everybody passed period of time when knows nothing about something.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform