PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • What is a critical section?
  • Using critical sections
  • Various
  • Equivalence
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
Marks the start of a critical section: no other thread will be able to run the code as long as the current thread does not exit from the critical section.
To exit from the critical section, use CriticalSectionEnd.
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 18 and later
Universal Windows 10 App This function is now available in Windows Store apps mode.
Android Widget This function is now available in Android Widget mode.
New in version 18
Universal Windows 10 App This function is now available in Windows Store apps mode.
Android Widget This function is now available in Android Widget mode.
Universal Windows 10 App This function is now available in Windows Store apps mode.
Android Widget This function is now available in Android Widget mode.
Versions 19 and later
WEBDEV - Server codeLinux This function is now available for the WEBDEV sites in Linux.
WINDEVLinux This function is now available for the WINDEV applications in Linux.
iPhone/iPad This function is now available for the iPhone/iPad applications.
New in version 19
WEBDEV - Server codeLinux This function is now available for the WEBDEV sites in Linux.
WINDEVLinux This function is now available for the WINDEV applications in Linux.
iPhone/iPad This function is now available for the iPhone/iPad applications.
WEBDEV - Server codeLinux This function is now available for the WEBDEV sites in Linux.
WINDEVLinux This function is now available for the WINDEV applications in Linux.
iPhone/iPad This function is now available for the iPhone/iPad applications.
Versions 21 and later
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.
New in version 21
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.
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
Example
CriticalSectionStart()
// Two threads will not be able to run this code at the same time
...
CriticalSectionEnd()
Syntax

Starting a critical section on a code section Hide the details

CriticalSectionStart([<Section Name>])
<Section Name>: Optional character string (with quotes)
Identifies the critical section. This parameter is used to identify the protected code sections.
If this parameter is not specified, an automatic critical section is implemented.
Note: the automatic critical section and the critical section corresponding to an empty string ("") are different.
Versions 21 and later
AndroidAndroid Widget Not available in Android and in Android Widget

Starting a critical section on a variable Hide the details

CriticalSectionStart([<Variable Name>])
<Variable Name>: Character string
Name of WLanguage variable that must be protected in a critical section.
New in version 21
AndroidAndroid Widget Not available in Android and in Android Widget

Starting a critical section on a variable Hide the details

CriticalSectionStart([<Variable Name>])
<Variable Name>: Character string
Name of WLanguage variable that must be protected in a critical section.
AndroidAndroid Widget Not available in Android and in Android Widget

Starting a critical section on a variable Hide the details

CriticalSectionStart([<Variable Name>])
<Variable Name>: Character string
Name of WLanguage variable that must be protected in a critical section.
Remarks

What is a critical section?

A critical section is a semaphore limited to a single thread on a single code section (process, procedure, ...).
Unlike the semaphores, a critical section can be used once only.
For example, a critical section can be used to protect a procedure for updating the window controls.
The start of critical section is signaled by CriticalSectionStart. A name can be given to this critical section.
Note: The critical sections are unique for the application that created them. They cannot be shared between several applications.

Using critical sections

To handle critical sections, the management mode of threads must be changed by ThreadMode (associated with the ThreadCriticalSection constant).

Various

Equivalence

SemaphoreStart("SemaphoreName")
is equivalent to:
CriticalSectionStart("MyCriticalSection")
Indeed, by default, SemaphoreStart creates a semaphore limited to a single thread.
Components
WINDEVWEBDEV - Server codeReports 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