PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

  • Tips
  • Use mode
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
ServiceWait (Function)
In French: ServiceTemporise
Pauses the current service during the specified duration.
Note: This function is ignored if it is not called in a Service application.
Example
// -- Running the service (called in loop) --

// Main loop of the service
// Check the presence of files in the directory
sFileList is string
sFileList = fListFile("c:\temp\entry\*.*", frNotRecursive)

// If files have been included in the directory, they are processed by the service
IF sFileList <> "" THEN
ProcessFileList(sFileList)
END

// Wait during 10 seconds between two loops
ServiceWait(10*100)
Syntax
ServiceWait(<Time-out>)
<Time-out>: Integer ou Duration
Time-out defined for the current thread of service (in hundredths of a second). 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).
Remarks

Tips

  • A Service application runs the "Service execution" process in loop. To avoid consuming the processor resources of computer, ServiceWait must be used at the end of this process.
  • Multitask, Time-out or ThreadPause must not be used in a Service application.

Use mode

ServiceWait is required if the service code does not perform a temporization or a wait.
The execution of ServiceWait is automatically ended if a request for stopping the service occurs.
Let's see a classification of types of services and the use cases of ServiceWait.
  • Category 1
    When ServiceWait is useless: when the service waits for an external request. For example:
    • a server for communicating by sockets that waits for a connection request (SocketWaitForConnection)
    • a service that waits for an external signal (EventWait)
    • a service waiting for an internal synchronization of threads.
    In these cases, ServiceWait is useless. However, a specific stop code must be used to interrupt the wait.
    Note: A standard service proposes services to the other processes: therefore, it is waiting for external "commands" and it is found in category 1 for which ServiceWait is useless.
  • Category 2
    When ServiceWait is not very useful: checks in quick loops (one second). For example, checking the status of a database file one a regular basis.
    The service stays for less than one second in the time-out and ThreadPause is sufficient. In a stop is requested, this stop will be performed at the end of the loop, therefore after a wait of a few seconds.
  • Category 3
    When ServiceWait is very useful: checks spaced out in time. For example, processing a spool of files in a directory with directory checks every 5 minutes.
    Note: In this case, a schedule task is recommended.
Components
WINDEVReports and Queries wd230vm.dll
Linux wd230vm.so
Minimum required version
  • Version 15
This page is also available for…
Comments
Click [Add] to post a comment