AYUDA EN LÍNEA
 WINDEVWEBDEV Y WINDEV MOBILE

Este contenido se ha traducido automáticamente.  Haga clic aquí  para ver la versión en inglés.
Ayuda / WLanguage / Funciones WLanguage / Funciones estándar / Funciones de Windows / Funciones de eventos de Windows
  • Differences between the Timer and TimerSys functions
  • Locking or non-locking operations
  • Execution time of procedure
  • Process for calling the timer
  • Process for calling the timer
  • Timer and sibling windows
  • Timer and Thread
  • Timer and Windows service
WINDEV
WindowsLinuxJavaReportes y ConsultasCódigo de Usuario (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Código Navegador
WINDEV Mobile
AndroidWidget Android iPhone/iPadIOS WidgetApple WatchMac Catalyst
Otros
Procedimientos almacenados
Periodically and automatically calls a WLanguage procedure. Called in the procedure, Timer 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 EndTimer.
Tip: In most cases, use the TimerSys.function.
Ejemplo
// Procedure used to display the time in EDT_TIME1 on a regular basis
PROCEDURE Display_Time()
EDT_Time1 = TimeSys()

// Process performed when opening the window or the page
// Display_Time will be automatically called every second
IF Timer("Display_Time", 100, 1) = 0 THEN
	Error("Unable to create the timer")
END
Sintaxis

Starting a procedure periodically Ocultar los detalles

<Result> = Timer(<Procedure name> , <Period>)
<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 in quotation marks..
<Period>: Integer or 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,
  • the duration in a readable format (e.g., '1s' or '10cs').
Observaciones
Windows

Differences between the Timer and TimerSys functions

  • Timer allows you to use a timer managed by WINDEV. 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 the TimerSys function.
Indeed, Timer consumes more resources than TimerSys and it operates only when WINDEV windows are displayed (the timer stops when a message box is displayed).
Windows

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

Execution time of procedure

If the time it takes to process the procedure called by timer is greater than the time requested between each call to the procedure, calls to the timer won't pile up: only one call will be waiting.
Windows

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 global procedure of 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 the code of a window, one of its controls or local procedures, 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 global procedure of 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 global procedure of 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 global procedure of the project:
      Timer("<global procedure>", 1000)
WEBDEV - Código NavegadorAjax

Process for calling the timer

If Timer is called in the code of a page, one of its controls or browser local procedures, the timer is associated with the page. The timer is interrupted by:
  • EndTimer,
  • the page validation,
  • the replacement of the page by another page in the browser.
The procedure called by the timer must be a local browser procedure on the page: Timer("<procédure locale>", 1000)
Windows

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

Timer and Thread

A procedure started by Timer or TimerSys from a secondary thread (ThreadExecute) will not be called. In fact, a secondary thread has no interface (i.e. no open window): this secondary thread does not receive messages from the system (the "message loop") like the application's main thread.
Windows

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).
Componente: wd300vm.dll
Versión mínima requerida
  • Versión 9
Esta página también está disponible para…
Comentarios
Exemlo de Timer
https://youtu.be/36yxeAZtZlE

http://windevdesenvolvimento.blogspot.com.br/2018/05/dicas-1758-publica-windev-novidade23-9.html

https://groups.google.com/d/forum/amarildowindev

// EXEMPLO

TIMER(MOSTRAR_HORA,5S)

// PROCEDURE

PROCEDORE MOSTRAR_HORA

STC_hora=TimeSys()


De matos
29 05 2018

Última modificación: 28/03/2025

Señalar un error o enviar una sugerencia | Ayuda local