PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

  • Overview
  • How to proceed?
  • Automating a procedure
  • Automating a procedure
  • Timer case/Scheduled procedures
  • Thread case
  • Case of main thread
  • Notes
  • Icon of automatic procedures
  • Summary table
  • "At the end of the event containing the call"
  • Stopping an automatic procedure
  • Procedure with automatic start of threads
  • Object-Oriented Programming (OOP)
  • Limitation for WEBDEV
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
Overview
The programming of timers, threads and delayed procedures is now automatically managed by the environment.
No need to program the processes and to synchronize them via the WLanguage code anymore, all you have to do is configure the automated procedure options.
No more TimerSys, Timer, ThreadExecute, ... These functions are still available for backward compatibility.
Some examples of processes that can be defined without a single code line:
  • run a procedure every 10 seconds (check an email box, check the presence of a file on the network, ...)
  • same, but starting 5 minutes after the program is run.
  • run the procedure in background task (in a thread), without waiting for its return value.
Versions 18 and later
WEBDEV - Server code This mechanism can also be used to run scheduled tasks and delayed tasks on the WEBDEV Application Server. See Scheduled tasks and delayed tasks for more details.
New in version 18
WEBDEV - Server code This mechanism can also be used to run scheduled tasks and delayed tasks on the WEBDEV Application Server. See Scheduled tasks and delayed tasks for more details.
WEBDEV - Server code This mechanism can also be used to run scheduled tasks and delayed tasks on the WEBDEV Application Server. See Scheduled tasks and delayed tasks for more details.
Versions 19 and later
WINDEV MobileAndroid This feature is now available for the Android applications.
WINDEV MobileAndroid Widget This feature is now available in Android Widget mode.
New in version 19
WINDEV MobileAndroid This feature is now available for the Android applications.
WINDEV MobileAndroid Widget This feature is now available in Android Widget mode.
WINDEV MobileAndroid This feature is now available for the Android applications.
WINDEV MobileAndroid Widget This feature is now available in Android Widget mode.
Versions 20 and later
WINDEV MobileiPhone/iPad This feature is now available for the iPhone/iPad applications.
WINDEVLinux This feature is now available for the WINDEV applications in Linux.
New in version 20
WINDEV MobileiPhone/iPad This feature is now available for the iPhone/iPad applications.
WINDEVLinux This feature is now available for the WINDEV applications in Linux.
WINDEV MobileiPhone/iPad This feature is now available for the iPhone/iPad applications.
WINDEVLinux This feature is now available for the WINDEV applications in Linux.
How to proceed?

Automating a procedure

To automate a procedure:
  1. Display the procedure code.
  2. Display the description window of the automated processes of the procedure:
    • Click Icon found in the procedure bar.
    • Select "Configure the automations of the procedure" from the popup menu of procedure ("Project explorer" pane).
    • Select "Properties" from the popup menu of procedure in the "Code" pane.
  3. In the window that is displayed, select the automations and their characteristics:
    • Running the procedure:
      Running the procedure
      By default, the procedure is run whenever it is called.
      The procedure can also be automatically run after the initialization code of the project (for a global procedure) or after the initialization code of the window or page (for a local procedure).
    • How many times:
      How many times

      The procedure can be run:
      • once: the procedure will be automatically stopped after its execution.
      • several times: the procedure will be run several times in a row. In this case, the procedure executions can be spaced out. A timer will be automatically implemented.
      • an infinite number of times: the procedure will be run an endless number of times. In this case, the procedure executions can be spaced out. A timer will be automatically implemented.
        If the executions are spaced out, this interval of time can be kept (or not) for the future calls to this procedure.
        If this interval of time is not kept ("Each following call runs the procedure once, without timer"), the procedure will be run once only when it is called.
        If this interval of time is kept ("Each following call restarts a new timer"), the procedure will be run an infinite number of times spaced out by the specified duration when it is called.
        Note: This option must be checked if the element (window or page) calling the procedure is used several times simultaneously (internal window and page for example).
    • When:
      When
      The procedure can be run:
      • immediately: the procedure is run as soon as it is called in the code and automatically after the initialization code (if "Automatic execution after the initialization code" was checked).
      • later: the procedure is run after the specified period.
        If the execution is delayed, this interval of time can be kept (or not) for the future calls to this procedure.
        If this time interval is not kept ("Each following call runs the procedure once, without timer"), the procedure will be run immediately when it is called.
        If this time interval is kept ("Each following call starts a new timer"), the procedure will be run after the specified duration when it is called
      • at the end of the process containing the call: the procedure is run when the process containing the call to the procedure is over.
      • at the end of event containing the call: the procedure is run when the process containing the call to the procedure is over. See ""At the end of the event containing the call" option" for more details.
    • How:
      How
      This option is used to specify whether the procedure must be run in background task (in a thread) and whether this thread must perform accesses to HyperFileSQL data files.
      WEBDEV - Server code Note: The timers are not available in WEBDEV. The automated processes for repetition and for delayed execution are not available.
      However, the use of a repeated automatic procedure can be configured because a set of procedures, a class, ... can be shared between several products.
    In the window that is displayed, select the properties of the procedure:
    • Type of automation to configure:
      Type
      By default, the procedure is run whenever it is called. The procedure can also be run:
      • automatically:
        • after the initialization code of project (for a global procedure)
        • after the initialization code of window or page (for a local procedure).
      • Versions 18 and later
        WEBDEV - Server code as scheduled task on a WEBDEV application server. See Scheduled tasks for more details.
        New in version 18
        WEBDEV - Server code as scheduled task on a WEBDEV application server. See Scheduled tasks for more details.
        WEBDEV - Server code as scheduled task on a WEBDEV application server. See Scheduled tasks for more details.
      • Versions 18 and later
        WEBDEV - Server code as delayed task on a WEBDEV application server. See Delayed tasks for more details.
        New in version 18
        WEBDEV - Server code as delayed task on a WEBDEV application server. See Delayed tasks for more details.
        WEBDEV - Server code as delayed task on a WEBDEV application server. See Delayed tasks for more details.
    • How many times:
      How many times
      The procedure can be run:
      • once: the procedure will be automatically stopped after its execution.
      • several times: the procedure will be run several times in a row. In this case, the procedure executions can be spaced out. A timer will be automatically implemented.
      • an infinite number of times: the procedure will be run an endless number of times. In this case, the procedure executions can be spaced out. A timer will be automatically implemented.
        If the executions are spaced out, this interval of time can be kept (or not) for the future calls to this procedure.
        If this interval of time is not kept ("Each following call runs the procedure once, without timer"), the procedure will be run once only when it is called.
        If this interval of time is kept ("Each following call restarts a new timer"), the procedure will be run an infinite number of times spaced out by the specified duration when it is called.
        Note: This option must be checked if the element (window or page) calling the procedure is used several times simultaneously (internal window and page for example).
    • When:
      When
      The procedure can be run:
      • immediately: the procedure is run as soon as it is called in the code and automatically after the initialization code (if "Automatic execution after the initialization code" was checked).
      • later: the procedure is run after the specified period.
        If the execution is delayed, this interval of time can be kept (or not) for the future calls to this procedure.
        If this time interval is not kept ("Each following call runs the procedure once, without timer"), the procedure will be run immediately when it is called.
        If this time interval is kept ("Each following call starts a new timer"), the procedure will be run after the specified duration when it is called
      • at the end of the process containing the call: the procedure is run when the process containing the call to the procedure is over.
      • at the end of event containing the call: the procedure is run when the process containing the call to the procedure is over. See ""At the end of the event containing the call" option" for more details.
    • How:
      How
      This option is used to specify whether the procedure must be run in background task (in a thread) and whether this thread must perform accesses to HFSQL data files.
      WEBDEV - Server code Note: The timers are not available in WEBDEV. The automated processes for repetition and for delayed execution are not available. However, the use of a repeated automatic procedure can be configured because a set of procedures, a class, ... can be shared between several products.

Automating a procedure

To automate a procedure:
  1. Display the procedure code.
  2. Display the description window of procedure automations:
    • Click Icon found in the procedure bar.
    • Select "Configure the automations of the procedure" from the popup menu of procedure ("Project explorer" pane).
    • Select "Properties" from the popup menu of procedure in the "Code" pane.
  3. In the window that is displayed, select the automation type:

Timer case/Scheduled procedures

The options are as follows:
  • Number of times:
    Number of times
    The procedure can be run:
    • once: the procedure will be automatically stopped after its execution.
    • several times: the procedure will be run several times in a row. In this case, the procedure executions can be spaced out. A timer will be automatically implemented.
    • an infinite number of times: the procedure will be run an endless number of times. In this case, the procedure executions can be spaced out. A timer will be automatically implemented.
      If the executions are spaced out, this interval of time can be kept (or not) for the future calls to this procedure.
      If this interval of time is not kept ("Each following call runs the procedure once, without timer"), the procedure will be run once only when it is called.
      If this interval of time is kept ("Each following call restarts a new timer"), the procedure will be run an infinite number of times spaced out by the specified duration when it is called.
      Note: This option must be checked if the element (window or page) calling the procedure is used several times simultaneously (internal window and page for example).
  • When:
    When
    The procedure can be run:
    • immediately: the procedure is run as soon as it is called in the code.
    • Automatic start: the procedure is run automatically after the initialization code (of window, page or project).
    • later: the procedure is run after the specified period.
      If the execution is delayed, this interval of time can be kept (or not) for the future calls to this procedure.
      If this time interval is not kept ("Each following call runs the procedure once, without timer"), the procedure will be run immediately when it is called.
      If this time interval is kept ("Each following call starts a new timer"), the procedure will be run after the specified duration when it is called
    • at the end of the process containing the call: the procedure is run when the process containing the call to the procedure is over.
    • at the end of event containing the call: the procedure is run when the process containing the call to the procedure is over. See "At the end of the event containing the call" for more details.
WEBDEV - Server code Note: The timers are not available in WEBDEV. The automated processes for repetition and for delayed execution are not available. However, the use of a repeated automatic procedure can be configured because a set of procedures, a class, ... can be shared between several products.

Thread case

This option is used to specify whether the procedure must be run in background task (in a thread).
The options are as follows:
  • Number of times:
    Number of times
    The procedure can:
    • be run once: the procedure will be automatically stopped after its execution.
    • be run several times: the procedure will be run several times in a row. In this case, the procedure executions can be spaced out. A timer will be automatically implemented.
    • be run an endless number of times: the procedure will be run an endless number of times. In this case, the procedure executions can be spaced out. A timer will be automatically implemented.
    • use HFSQL or not: This option is used to specify whether the thread must access the HFSQL data files.
      Two types of accesses are possible:
      • Full copy of context: Used copy the context of connections, positions, queries, ...
      • Versions 20 and later
        Light copy of context: Used to copy the context of connections only.
        New in version 20
        Light copy of context: Used to copy the context of connections only.
        Light copy of context: Used to copy the context of connections only.
  • When:
    When
    The procedure can be run:
    • immediately: the procedure is run as soon as it is called in the code and automatically after the initialization code (if "Automatic execution after the initialization code" was checked).
    • later: the procedure is run after the specified period.
      If the execution is delayed, this interval of time can be kept (or not) for the future calls to this procedure.
      If this time interval is not kept ("Each following call runs the procedure once, without timer"), the procedure will be run immediately when it is called.
      If this time interval is kept ("Each following call starts a new timer"), the procedure will be run after the specified duration when it is called
    • at the end of the process containing the call: the procedure is run when the process containing the call to the procedure is over.
    • at the end of event containing the call: the procedure is run when the process containing the call to the procedure is over. See "At the end of the event containing the call" for more details.
Versions 20 and later

Case of main thread

This option allows you to call a procedure in the main thread from a secondary thread. This option is mainly used to access the GUI. This option is equivalent to ExecuteMainThread.
New in version 20

Case of main thread

This option allows you to call a procedure in the main thread from a secondary thread. This option is mainly used to access the GUI. This option is equivalent to ExecuteMainThread.

Case of main thread

This option allows you to call a procedure in the main thread from a secondary thread. This option is mainly used to access the GUI. This option is equivalent to ExecuteMainThread.
Notes

Icon of automatic procedures

As soon as a procedure is automated, the icon icon found on the right in the bar of procedure becomes Icon
The icon found on the left in the procedure bar indicates the type of automation for the procedure:
  • repeated procedure: Repeated Procedure icon
  • delayed procedure: Delayed Procedure icon
  • repeated procedure with thread: Repeated Procedure with Thread icon
  • procedure run in a thread: Procedure Run in a Thread icon
  • repeated procedure with timer: Repeated Procedure with Timer icon
  • delayed repeated procedure in a thread: Delayed Repeated Procedure in a Thread icon

Summary table

The following table presents the different cases for running procedures according to the selected automated options:
Next calls without keeping the interval of time or the time-outNext calls while keeping the interval of time or the time-out
Delayed procedure ("Delayed" checked)1st manual callTime-out then run the procedureTime-out then run the procedure
Next callsRun the procedureTime-out then run the procedure
Delayed procedure, repeated with time-out ("Delayed", "Infinite" and "Space out the calls" checked)1st manual callTime-out -> Procedure -> Time-out-> Procedure...Time-out -> Procedure -> Time-out-> Procedure...
Next callsRun the procedure (once only)Time-out -> Procedure -> Time-out-> Procedure...
Delayed procedure, automatically run ("Delayed" and "Automatic execution..." checked)Automatic 1st callTime-out then run the procedureTime-out then run the procedure
Next callsRun the procedureTime-out then run the procedure
Delayed procedure, automatically run, repeated with time-out ("Delayed", "Infinite", "Space out the calls" and "Automatic execution..." checked)Automatic 1st callTime-out -> Procedure -> Time-out-> Procedure...Time-out -> Procedure -> Time-out-> Procedure...
Next callsRun the procedure (once only)Time-out -> Procedure -> Time-out-> Procedure...

"At the end of the event containing the call"

The procedures for which the option "At the end of the event containing the call" is checked and called from a callback procedure (procedure used by fListFile, Event, ...) are run at the end of each call to the callback.
Example:
// -----------------
// standard case
// -----------------
Click of button
// beginning of button click code
Proc1
// beginning of Procedure1 code
Proc2
// beginning of Procedure2 code

Call to EndEvent procedure
// end of Proc2 code
// end of Proc1 code
// end of button click code
Execution of EndEvent procedure
// -------------------
// callback case
// -------------------
Click of button
Proc1
Proc2
use of fListFile
Callback1 procedure
// beginning of code of Callback1 Procedure
CallbackProc2
// beginning of code of Callback2 Procedure
Call to ProcEndEvent
// end of ProcedureCallback2 code
// end of ProcedureCallback1 code
Execution of ProcEndEvent
ProcedureCallback1
// beginning of ProcedureCallback1 code
ProcedureCallback2
// beginning of ProcedureCallback2 code
Call to ProcEndEvent
// end of ProcedureCallback2 code
// end of ProcedureCallback1 code
Execution of ProcEndEvent

Stopping an automatic procedure

To stop an automatic procedure, all you have to do is use EndAutomatedProcedure.

Procedure with automatic start of threads

Reminder: In WLanguage, by default, each procedure creates an automatic critical section. Therefore, two threads cannot run the same procedure at the same time.
If a procedure that automatically triggers a thread is called twice:
  • in default mode: the first procedure is run and the second procedure waits for the first one to stop before it is run.
  • in threadCriticalSection mode (defined by ThreadMode), the two threads are triggered at the same time.

Object-Oriented Programming (OOP)

When a procedure automation is defined on a class method for an endless execution by timer, a single call can be done for all the instances:
  • if the method automation is configured with "Perform the call only" : only one of the class instances will perform the call to the method via the timer.
  • if the method automation is configured with "Start an additional timer" : all the class instances will perform the call to the method for the current instance.
If the automation is configured for an endless execution in a thread, all the class instances will perform a call to the method for the current instance.
WEBDEV - Server code

Limitation for WEBDEV

The timers are not available in WEBDEV. The automated processes for repetition and for delayed execution are not available.
Note: However, the use of a repeated automatic procedure can be configured because a set of procedures (or a class, ...) can be shared between several products.
Related Examples:
The Chrono functions Unit examples (WINDEV): The Chrono functions
[ + ] Using the ChronoXXX functions.
These functions are used to calculate the time passed between the start (ChronoStart) and the end (ChronoEnd).
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
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 (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
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 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)
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).
Minimum required version
  • Version 10
This page is also available for…
Comments
Click [Add] to post a comment