Note: If this parameter corresponds to the name of an internal procedure, the name of internal procedure must not be enclosed between quotes.

<Period>: Integer ou Duration

Time (in hundredths of a second) between two calls to the procedure by timer. The period precision depends on the pending system status.This parameter can correspond to:

an integer corresponding to the number of hundredths of a second,

a Duration variable,

Versions 23 and laterthe direct indication of the duration ('1s' or '10cs' for example).

New in version 23the direct indication of the duration ('1s' or '10cs' for example).

the direct indication of the duration ('1s' or '10cs' for example).

<Number>: Optional integer

Number imposed to the timer. If this parameter is specified, the timer number will be the selected number. If this number corresponds to an existing timer, it will be stopped and replaced by the new timer.

This parameter is not available. In this version, no number can be imposed to the timer. If the timer must be stopped by programming before closing the page, the timer number must be stored (<Result> parameter) in order to be used in EndTimer.

If the time used to process the procedure called by the timer is greater than the time requested between each call to the procedure, the calls to the timer do not pile up: there will be a single pending call.

Process for calling the timer

Code of the project:

If Timer is called in a project code, the timer is associated with the project. The timer is interrupted by EndTimer and when the execution of the application is over. The procedure called by the timer must be:

a procedure global to the project:

Timer("<global procedure>", 1000)

No parameter can be passed to the procedure called (use global variables).

a static method of a class:

Timer("<class>::<static method>", 1000)

If Timer is used in the opening process of project and if no window is opened, the timer will be valid for the entire project. It is in a pending status and it will be automatically triggered as soon as a window is opened or during the calls to Multitask.

Code of a window, control or local procedure:If Timer is called in a code of a window, window control or procedure local to the window, the timer is associated with the window. The timer is interrupted by EndTimer and when closing the window. The procedure called by the timer must be:

a local procedure of the window:

Timer("<local procedure>", 1000)

No parameter can be passed to the procedure called (use global variables).

a procedure global to the project:

Timer("<global procedure>", 1000)

No parameter can be passed to the procedure called (use global variables).

a static method of a class:

Timer("<class>::<static method>", 1000)

Code of a static method of a class:If Timer is called in a static method of a class, the timer is associated with the class. The timer is interrupted by EndTimer and when the execution of the application is over. The procedure called by the timer must be:

a static method of the class:

Timer("::<static method>", 1000)

a static method of another class:

Timer("<class>::<static method>", 1000)

a procedure global to the project:

Timer("<global procedure>", 1000)

Code of an object method:If Timer is called in a method of an object, the timer is associated with the object. The timer is interrupted by EndTimer or when freeing the object. The procedure called by the timer must be:

a non-static method of the object:

Timer("<:method>", 1000)

a static method of the object class:

Timer("::<static method>", 1000)

a static method of another class:

Timer("<class>::<method>", 1000)

a procedure global to the project:

Timer("<global procedure>", 1000)

Process for calling the timer

If Timer is called in a code of a page, page control or browser procedure local to the page, the timer is associated with the page. The timer is interrupted by:

The procedure called by the timer must be a browser procedure local to the page: Timer("<local procedure&gt", 1000)

Timer and sibling windows

When the same window that manages a timer is opened several times (sibling windows in MDI mode), Timer must be used with no timer number. Therefore, a timer number will be automatically assigned to each window.

Timer and Thread

A procedure started by Timer or TimerSys from a secondary thread (ThreadExecute) will not be called. Indeed, a secondary thread has no interface (which means no opened window): this secondary thread does not receive the messages from the system (the "message loop") like the main application thread.

Timer and Windows service

To use Timer from a Windows service, this function must be called from a window opened by the service code.

Caution: This solution is not recommended. To repeat a process from a service, we advise you to call this process from the code of the service (the code of the service being run in loop).

Related Examples:

Unit examples (WINDEV): The alarms

[ + ] Implementing an alarm to display an alert message in the title bar of the active window (regardless of the application). The following topics are presented:1/ The system functions (retrieving the handle of a window)2/ Triggering a process according to a given frequency (timers)

Training (WINDEV): WD Screen Saver

[ + ] This example illustrates the creation of a screen saver with the WLanguage functions.The following topics are presented in this example:1/ the periodic call to a procedure ("timers")2/ the management of Windows events 3/ the system functions (call to Windows APIs)To use the screen saver:- Rename the executable (.EXE) to .SCR- Copy the file to the directory of Windows (Ex: C:\WINDOWS)- Open the window for the display properties of the desktop- Choose the "Screen Saver" tab- Select the screen saver generated by WINDEV

Training (WINDEV): WD Who is locking

[ + ] This example explains how to notify to the users of a HFSQL database in network "who" is locking an inaccessible record.

The following topics are presented in this example:1/ management of concurrent accesses2/ automatic refresh by timer3/ management of a "system" file to store information about the locks.

Summary of the example supplied with WINDEV: This example, powered by WINDEV, includes 2 projects:- WD Who is locking: test application that manages a "client" file in network- WD Supervisor of locks: management tool used to view the existing locks and to force the unlocking if necessary.An edit form may have been left opened by a user for quite a long time ; this may interfere with the other users.The 'Free' button sends a message to the relevant user and asks him to free the record.The 'Unlock!' button is used to force the unlocking of the record. Caution: This operation will send a message forcing the closing of the application that performed the lock.

Unit examples (WINDEV Mobile): Managing the timers

[ + ] Implementing a timer:- start a timer- run a code whenever the timer is called- stop a timer

Unit examples (WINDEV Mobile): The Chrono functions

[ + ] Using the WLanguage "Chrono" functions.These functions are used to calculate the time passed between the start (ChronoStart) and the end (ChronoEnd).

Unit examples (WEBDEV): Managing the timers

[ + ] This example explains how to implement a timer and it allows you to:- Start a timer- Run a code whenever the timer is called- Stop a timer