Connection Information

To perform the requested action, WordPress needs to access your web server. Please enter your FTP credentials to proceed. If you do not remember your credentials, you should contact your web host.

Connection Type

Syntax 2 For activating timing objects – PB Docs 126 – PowerBuilder Library

Syntax 2 For activating timing objects – PB Docs 126

Syntax 2 For activating timing objects

Description

Activates a timing object causing a Timer event to occur repeatedly
at the specified interval.

Controls

Timing objects

Syntax

Argument

Description

timingobject

The name of the timing object you want
to activate.

interval

An expression of type double specifying
the number of seconds that you want between timer events. The interval can be
a whole number or fraction greater than 0 and less than or equal
to 4,294,967 seconds. An interval of 0 is invalid.

Return Values

Integer. Returns 1 if it succeeds and
-1 if the timer is already running, the interval specified is invalid,
or there are no system timers available.

Usage

This syntax of the Start function is used
to activate a nonvisual timing object. Timing objects can be used
to trigger a Timer event that is not associated with a PowerBuilder
window, and they are therefore useful for distributed PowerBuilder
servers or shared objects that do not have a window for each client
connection.

A timing object is a standard class user object inherited
from the Timing system object. Once you have created a timing object
and coded its timer event, you can create any number of instances
of the object within the constraints of your operating system. An
operating system supports a fixed number of timers. Some of those
timers will already be in use by PowerBuilder and other applications
and by the operating system itself.

To activate an instance of the timing object, call the Start function,
specifying the interval that you want between
Timer events. The Timer event of that instance is triggered as soon
as possible after the specified interval, and will continue to be
triggered until you call the Stop function on
that instance of the timing object or the object is destroyed.

note.png When the Timer event occurs

The interval specified for the Start function
is the minimum interval between Timer events. All other posted events
occur before the Timer event.

The resolution of the interval depends on your operating system.

You can determine what the timing interval is and whether
a timer is running by accessing the timing object’s Interval
and Running properties. These properties are read-only. You must
stop and restart a timer in order to change the value of the timing
interval.

note.png Garbage collection

If a timing object is running, it is not subject to garbage
collection. Garbage collection can occur only if the timing object
is not running and there are no references to it.

Examples

[Example 1]

Suppose you have a distributed application in which the local client
performs some processing, such as calculating the value of a stock portfolio,
based on values in a database. The client requests a user object
on a remote server to retrieve the data values from the database.

Create a standard class user object on the server called uo_timer,
inherited from the Timing system object, and code its Timer event
to refresh the data. Then the following code creates an instance, MyTimer,
of the timing object uo_timer. The Start function
activates the timer with an interval of 60 seconds so that the request
to the server is issued at 60-second intervals:

[Example 2]

The following example uses a timing object as a shared object
in a window that has buttons for starting a timer, getting a hit
count, stopping the timer, and closing the window. Status is shown
in a single line edit called sle_state.
The timing object, uo_timing, is a
standard class user object inherited from the Timing system object.
It has one instance variable that holds the number of times a connection
is made:

The timing object uo_timing has
three functions:

  • of_connect increments il_hits and
    returns an integer (this example omits the connection code for simplicity):

  • of_hitcount returns
    the value of il_hits:

  • of_resetcounter resets
    the value of the counter to 0:

The timer event in uo_timing calls
the of_connect function:

When the main window (w_timer)
opens, its Open event script registers the uo_timing user
object as a shared object:

The Start Timer button starts the timer with an interval
of five seconds:

The Get Hits button calls the of_hitcount function
and writes the result in a single line edit:

The Stop Timer button stops the timer, reenables
the Start Timer button, and resets the hit counter:

The Close button checks that the timer has been stopped
and closes the window if it has:

The Close event for the window unregisters the shared
timing object:

The of_converterror window
function converts the ErrorReturn enumerated type to a string. It
takes an argument of type ErrorReturn:

See Also


Document get from Powerbuilder help
Thank you for watching.
Was this article helpful?
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x