Help / WLanguage / WLanguage functions / Standard functions / Process functions / Threads, semaphores, signals and mutex
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WindowsLinuxPHPWEBDEV - Browser code
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Stored procedures
Makes a thread persistent.
The application is not stopped as long as at least one persistent thread is running (even if all its windows have been closed).
Using a persistent thread allows you to:
  • continue playing music even if the window is closed.
  • transmit GPS coordinates on a permanent basis.
// Start the thread that triggers the reading of a sound track
ThreadExécute("MyThread", threadGlobalContext, ProcPlayMusic)
// Creates the notification to display while playing the sound track
Notif is Notification
Notif.Title = "Playing..."
Notif.ActionClick = ProcStopMusic
// Make the thread persistent to prevent the application from being closed
// as long as the thread is not ended
ThreadPersistent("MyThread", Notif)
<Result> = ThreadPersistent(<Thread name> , <Notification to Display>)
<Result>: Boolean
  • True if the thread was made persistent,
  • False if an error occurred. To get more details on the error, use ErrorInfo with the errMessage constant.
<Thread name>: Character string
Name of the thread that must become persistent. This name is given when running the thread (ThreadExecute). This thread must exist and it must use the global context of the application.
<Notification to Display>: Notification variable
Name of the Notification variable corresponding to the notification that must displayed during the execution of the persistent thread.
This notification must not be already displayed. If a persistent thread is running when ThreadPersistent is called, the notification associated with this thread will be replaced with the specified notification. When the thread execution is ended, the notification will be automatically hidden if no other persistent thread is in progress.
  • A notification is always displayed during the execution of a persistent thread. Therefore, the user is informed that the started application is still running even if no window is opened. He can take control over this application during a click on the notification.
    The application can also be restarted during a click on the notification: to do so, specify the ActivateApplication property in the Notification variable.
  • Tip: No window must be opened from a persistent thread. The windows can be opened from the procedure called by the notification for example.
  • Starting with Android 10, optimizing the use of the integrated battery can interrupt a thread made persistent with ThreadPersistent. In this case, SysBatteryOptimBackground allows the application to use the battery and also keeps the persistent thread.
Related Examples:
Android Persistent Notifications Android (WINDEV Mobile): Android Persistent Notifications
[ + ] This example is used to create persistent notifications that appear even if the application is not used anymore.
A persistent thread run when the starting device is used to send the notifications.
Component: wd290android.jar
Minimum version required
  • Version 18
Click [Add] to post a comment

Last update: 06/22/2023

Send a report | Local help