ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Standard functions / Windows functions / Windows Event functions
  • Differences between the Timer and TimerSys functions
  • Process for calling the timer
  • Locking or non-locking operations
  • Execution time of procedure
  • Timer and sibling windows
  • Timer and Thread
  • Timer and Windows service
  • Timer and user interactions: scrolls, gestures, ...
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Periodically and automatically calls a WLanguage procedure. Called in the procedure, TimerSys is used to identify the timer that started the procedure.
The sequence of periodic calls to a procedure is called timer. This periodic call will be stopped by EndTimerSys.
WINDEVWINDEV Mobile Automatic procedures can be used instead of TimerSys. For more details, see the automatic procedures.
Example
// Procedure used to display the time in EDT_Time1 on a regular basis
PROCÉDURE Display_Time()
EDT_Time1 = TimeSys()
 
// Process when opening the window
// Display_Time will be called every second
IF TimerSys("Display_Time", 100, 1) = 0 THEN
Error("Unable to create the timer")
END
Syntax

Starting a procedure periodically Hide the details

<Result> = TimerSys(<WLanguage procedure> , <Period> [, <Number>])
<Result>: Integer
  • Number of the opened timer (<Number> if this parameter is specified),
  • 0 if the timer was not opened.
<WLanguage procedure>: Procedure name
Name of WLanguage procedure that will be started periodically.
Remark: If this parameter corresponds to the name of an internal procedure, the name of internal procedure must not be enclosed between quotes.
<Period>: Integer
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 be:
  • an integer corresponding to the number of hundredths of a second,
  • a Duration variable,
  • the duration in a readable format (e.g., 1 s or 10 ms).
<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 with the new timer.

Finding out the timer number Hide the details

<Result> = TimerSys()
<Result>: Integer
Number of the timer that called the current procedure.
Remarks

Differences between the Timer and TimerSys functions

  • Timer allows you to use a timer managed by WINDEV or WINDEV Mobile. In this case, the frequency of the call is calculated from the moment when the call to the timer was performed.
  • TimerSys allows you to use a timer managed by the system. In this case, the frequency of the call is calculated from the end of the procedure execution.
Tip: In most cases, use TimerSys.
Indeed, Timer consumes more resources than TimerSys and it operates only when WINDEV/WINDEV Mobile windows are displayed (the timer stops if a message box is displayed).

Process for calling the timer

  • Code of the project:
    • If TimerSys is called in a project code, the timer is associated with the project. The timer is interrupted by EndTimerSys and when the execution of the application is over. The procedure called by the timer must be:
      • a procedure global to the project:
        TimerSys("<global procedure>", 1000)
      • a static method of a class:
        TimerSys("<class>::<static method>", 1000)
    • If TimerSys 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 TimerSys is called in the code of a window, one of its controls or local procedures, the timer is associated with the window. The timer is interrupted by EndTimerSys and when closing the window. The procedure called by the timer must be:
    • a local procedure of the window:
      TimerSys("<local procedure>", 1000)
    • a procedure global to the project:
      TimerSys("<global procedure>", 1000)
    • a static method of a class:
      TimerSys("<class>::<static method>", 1000)
  • Code of a static method of a class:
    If TimerSys is called in a static method of a class, the timer is associated with the class. The timer is interrupted by EndTimerSys and when the execution of the application is over. The procedure called by the timer must be:
    • a static method of the class:
      TimerSys ("::<static method>", 1000)
    • a static method of another class:
      TimerSys("<class>::<static method>", 1000)
    • a procedure global to the project:
      TimerSys("<global procedure>", 1000)
  • Code of an object method:
    If TimerSys is called in a method of an object, the timer is associated with the object. The timer is interrupted by EndTimerSys, when freeing the object and when closing the window. The procedure called by the timer must be:
    • a non-static method of the object:
      TimerSys(":<method>", 1000)
    • a static method of the object class:
      TimerSys ("::<static method>", 1000)
    • a static method of another class:
      TimerSys("<class>::<method>", 1000)
    • a procedure global to the project:
      TimerSys("<global procedure>", 1000)

Locking or non-locking operations

  • A timer is not locked when opening menus, when opening a window, when opening the windows associated with Warning, Confirm, Error, Info, OKCancel and YesNo.
  • A timer is locked when the windows are moved or resized.

Execution time of procedure

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.
WINDEVReports and QueriesJavaUser code (UMC)

Timer and sibling windows

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

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.
WINDEV

Timer and Windows service

To use TimerSys 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).
iPhone/iPad

Timer and user interactions: scrolls, gestures, ...

The user interactions (scrolls, gestures) have priority over the timers.
For example, scrolling through a Looper control will block the execution of a procedure called by TimerSys.
If a procedure must be run during the user interactions, this procedure must be started by ThreadExecute.
Related Examples:
WD Screen Saver 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
The alarms 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)
WD Who is locking 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 accesses
2/ automatic refresh by timer
3/ 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.
Managing the timers Unit examples (WINDEV Mobile): Managing the timers
[ + ] Implementing a timer:
- start a timer
- run a code whenever the timer is called
- stop a timer
The Chrono functions 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).
Android Inventory Android (WINDEV Mobile): Android Inventory
[ + ] This application is used to perform inventories and to save the results in a database.
Managing the timers 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
Component: wd300vm.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 06/22/2023

Send a report | Local help