PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK
  • Special case: Stopping a thread that contains the SocketWairForConnexion function
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
Warning
This function is not recommended because it violently stops the current thread. It may trigger serious problems (incomplete file writing, loss of memory, critical section not freed, ...). We recommend that you use ThreadRequestStop and ThreadStopRequested.
Stops a secondary thread.
Reminder: A thread is a process run in parallel of current application (main thread). This allows you to run a task in background task for example (backup, ...).
Versions 17 and later
Universal Windows 10 App This function is now available for Windows Phone applications.
New in version 17
Universal Windows 10 App This function is now available for Windows Phone applications.
Universal Windows 10 App This function is now available for Windows Phone applications.
Versions 19 and later
Universal Windows 10 App This function is now available in Windows Store Apps mode.
iPhone/iPad This function is now available for iPhone/iPad applications.
WEBDEV - Server codeLinux This function is now available for WEBDEV sites in Linux.
WINDEVLinux This function is now available for WINDEV applications in Linux.
New in version 19
Universal Windows 10 App This function is now available in Windows Store Apps mode.
iPhone/iPad This function is now available for iPhone/iPad applications.
WEBDEV - Server codeLinux This function is now available for WEBDEV sites in Linux.
WINDEVLinux This function is now available for WINDEV applications in Linux.
Universal Windows 10 App This function is now available in Windows Store Apps mode.
iPhone/iPad This function is now available for iPhone/iPad applications.
WEBDEV - Server codeLinux This function is now available for WEBDEV sites in Linux.
WINDEVLinux This function is now available for WINDEV applications in Linux.
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.
Syntax
<Result> = ThreadStop(<Thread name> [, <Maximum timeout>])
<Result>: Boolean
  • True if the thread was stopped or if the thread does not exist,
  • False if the thread is locked
<Thread name>: Character string (with quotes)
Name of thread to stop. This name is given when running the thread (ThreadExecute).
Special cases:
  • If this parameter corresponds to an empty string (""), the current thread is stopped. If the current thread is the main thread, ThreadStop is equivalent to EndProgram.
    Universal Windows 10 App Only this behavior is allowed. ThreadStop can only be used on the current thread.
  • If the name of the thread does not exist, ThreadStop has no effect and it returns True.
  • If the name of the thread is a child thread or a sibling thread, ThreadStop waits for the current WLanguage function (HReadFirst for example) to end. In this case, ThreadStop is a locking function.
  • If this parameter corresponds to the threadMain constant, the main thread is stopped.
  • Otherwise, a WLanguage error is triggered.
<Maximum timeout>: Optional integer
Maximum timeout in hundredths of a second.
  • If the thread is not stopped at the end of specified duration, <Result> is set to False.
  • If this parameter is not specified or if it corresponds to the Infinite constant, the wait is infinite.
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

Special case: Stopping a thread that contains the SocketWairForConnexion function

In order for the thread to be properly stopped by ThreadStop, SocketWaitForConnection must be included in a loop:
Timeout = 30
LOOP
SocketWaitForConnection("MySocket", Duration)
END
Component : wd250vm.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Video Thread
https://youtu.be/4WYw-BGyh1w

https://windevdesenvolvimento.blogspot.com/2019/01/dicas-1997-windev-threads-03-threadstop.html

amarildo
25 Jan. 2019