Using Timers in Background

Panorama Help says…
“When a timer is operating in either database or window scope, the timer normally won’t run when the database or window is not the active database or window. However, if the background property is true, the timer will always run, even when some other database or window is active. Before running the timer task, Panorama will automatically set up a secret window for the database associated with the timer.”

What will happen if another database opens the database with the Background timer running and does a search or update a record. Will the timer wait until the current operation is done?

Timers are all paused whenever procedure code is running. If a time is goes off, but some other code is already running, the timer code will wait until whatever is running is finished.

Suppose you have a timer set to run every second, but then you run another procedure that takes 5 seconds. The timer will pause for 5 seconds. When it restarts, it will just resume the 1 second intervals, it will NOT make up the 4 slots that were missed.

Timers also don’t run when a dialog is open.

In spite of this, I would recommend using background timers sparingly. They can provide quite a jarring experience for users, as Panorama suddenly does something unexpected.

What I would be doing is like it is described in Panorama Help, I would have a open but hidden database run a timer in the background that would every 15 seconds look for a text file and update the hidden database. The user will be working in a different database. With this scenario it should not interrupt the user at all correct?

Well, maybe. It somewhat depends on what your timer code does. Obviously if every 15 seconds the timer performs a 5 second task, the user is going to notice that. The timer code won’t interrupt the user, but when the timer code is running, the user won’t be able to do anything either, in other words the user can’t interrupt the timer code. Panorama only can do one thing at a time.

The Panorama X Server Administration window, which you haven’t seen yet, periodically checks the server and refreshes the status display. It uses a timer like you are planning to. It’s set up so that you can specify how often the refresh is and whether or not it continues refreshing in the background. I’ve found that I usually leave the background refresh off, because if I click on a menu at the exact time the timer goes off, it may not work (because the other database is temporarily active). Not a huge deal, I just have to click on the menu again, but it’s a bit of a "what just happened – oh, right’ sensation. This doesn’t happen very often, but enough that it bugged me. On the other hand, if I do want background refresh, I want it frequent so I set it to every second. If you are only doing it every 15 seconds it should be much less noticeable. Also, you won’t be doing network activity in your timer, so it may be faster/less noticeable. Basically, I think the only way you’ll know for sure is to try it.

Understood. Thank you Jim. :slight_smile: