ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Standard functions / Process functions / Threads, semaphores, signals and mutex
  • Miscellaneous
  • Equivalence
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
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.
WindowsLinuxUniversal Windows 10 AppiPhone/iPadApple Watch When the calls to CriticalSectionStart and CriticalSectionEnd are in the same section of the code, it is recommended to use the type CriticalSection and the syntax USE ... IN.
Example:
// Using a Critical Section variable
S is CriticalSection
 
// Use for a code block
//---------------------------
USING S IN
// code protected by the critical section
// only one thread will execute this code at a given moment
END
Example
WindowsLinuxUniversal Windows 10 AppiPhone/iPadApple Watch
// Critical section on a variable
t is array <critical section> of int
CriticalSectionStart(t)
// Operations on the array by one only thread at a time
CriticalSectionEnd(t)
// Use of a named critical section
CriticalSectionStart("MySection")
// Two threads will not be able to run this code at the same time
...
CriticalSectionEnd("MySection")
Syntax
WindowsLinuxUniversal Windows 10 AppiPhone/iPadApple Watch

Starting a critical section on a code section: using the CriticalSection type Hide the details

CriticalSectionStart(<Critical section>)
<Critical section>: CriticalSection variable
Name of the CriticalSection variable used to identify the critical section.
WindowsLinuxUniversal Windows 10 AppiPhone/iPadApple Watch

Starting a critical section on a variable Hide the details

CriticalSectionStart([<Variable name>])
<Variable name>: Any type
Name of WLanguage variable that must be protected in a critical section. This variable must be defined with the <critical section> attribute.

Starting a named critical section on a code section Hide the details

CriticalSectionStart([<Section name>])
<Section name>: Optional character string
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.
Remark: the automatic critical section and the critical section corresponding to an empty string ("") are different.
Remarks

Miscellaneous

  • For more details on critical sections, see Managing the critical sections.
  • If a thread is destroyed while it is found in a critical section, the critical section is automatically freed.
  • A single thread is allowed in all the sections with the same name.
  • If sections use a different name, a thread can run the code of one section while another thread runs the code of another section.
  • For more details, see Associating a critical section with a variable.

Equivalence

SemaphoreStart("SemaphoreName")
is equivalent to:
CriticalSectionStart("MyCriticalSection")
Indeed, by default, SemaphoreStart creates a semaphore limited to a single thread.
Component: wd290vm.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 06/21/2023

Send a report | Local help