PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • 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/iPadApple WatchUniversal Windows 10 AppWindows Mobile
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. See the automatic procedures for more details.
Versions 15 and later
Android This function is now available for the Android applications.
New in version 15
Android This function is now available for the Android applications.
Android This function is now available for the Android applications.
Versions 16 and later
WINDEVLinux This function is now available for the WINDEV applications in Linux.
New in version 16
WINDEVLinux This function is now available for the WINDEV applications in Linux.
WINDEVLinux This function is now available for the WINDEV applications in Linux.
Versions 17 and later
iPhone/iPad This function is now available for the iPhone/iPad applications.
Universal Windows 10 App This function is now available for the Windows Phone applications.
New in version 17
iPhone/iPad This function is now available for the iPhone/iPad applications.
Universal Windows 10 App This function is now available for the Windows Phone applications.
iPhone/iPad This function is now available for the iPhone/iPad applications.
Universal Windows 10 App This function is now available for the Windows Phone applications.
Versions 18 and later
Universal Windows 10 App This function is now available in Windows Store apps mode.
New in version 18
Universal Windows 10 App This function is now available in Windows Store apps mode.
Universal Windows 10 App This function is now available in Windows Store apps mode.
Versions 21 and later
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
Apple Watch This function is now available in Apple Watch mode.
New in version 21
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
Apple Watch This function is now available in Apple Watch mode.
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
Apple Watch This function is now available in Apple Watch mode.
Example
// Procedure used to display the time in EDT_Time1 on a regular basis
PROCÉDURE Disp_Time()
EDT_Time1 = TimeSys()

// Process when opening the window
// Disp_Time will be automatically called every second
IF TimerSys("Disp_Time", 100, 1) = 0 THEN
Error("Unable to create the timer")
END
Syntax

Starting a procedure periodically Hide the details

<Result> = TimerSys(<Procedure Name> , <Period> [, <Number>])
<Result>: Integer
  • Number of the opened timer (<Number> if this parameter is specified),
  • 0 if the timer was not opened.
<Procedure Name>: Character string
Name of WLanguage procedure that will be started periodically.
Note: If this parameter corresponds to the name of an internal procedure, the name of the 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 status of the system.
This parameter can correspond to:
  • an integer corresponding to the number of hundredths of a second,
  • a Duration variable,
  • Versions 23 and later
    the direct indication of duration (1 s or 10 ms for example).
    New in version 23
    the direct indication of duration (1 s or 10 ms for example).
    the direct indication of duration (1 s or 10 ms 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.

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 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 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 a Looper control will be a locking operation for 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
Components
WINDEVReports and Queries wd230vm.dll
Windows Mobile wp230vm.dll
Java wd230java.jar
Linux wd230vm.so
Android wd230android.jar
Minimum required version
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment