PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | English EN
This content has been translated automatically. Click here to view the French version.
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
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.
Example
// Lancement du thread déclenchant la lecture d'un morceau de musique
ThreadExécute("MonThread", threadGlobalContext, ProcJoueMusique)
 
// Crée la notification à afficher pendant la lecture du morceau de musique
Notif is Notification
Notif.Title = "Lecture en cours ..."
Notif.ActionClick = ProcStopMusique
 
// Rend le thread persistant pour empêcher la fermeture de l'application
// tant que le thread n'est pas terminé
ThreadPersistent("MonThread", Notif)
Syntax
<Result> = ThreadPersistent(<Thread name> , <Notification to Display>)
<Result>: Boolean
  • True if the thread was made persistent,
  • False if an error occurred. To get the details of the error, use ErrorInfo with the errMessage constant.
<Thread name>: Character string (with quotes)
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 the ThreadPersistentfunction is called, the Notification associated with this thread will be replaced by the Notification specified. When the thread execution is ended, the notification will be automatically hidden if no other persistent thread is in progress.
Remarks
  • A notification is necessarily 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: you just have to fill in the Property ActiveApplication in the Variable of type Notification.
  • Tip: No window must be opened from a persistent thread. The windows can be opened from the procedure called by the notification for example.
  • Optimizing the use of the built-in battery from Android version 10 onwards can interrupt an Thread made persistent by the ThreadPersistentfunction. In this case, the SysOptimBatteryBackground function allows the application to use the battery and thus also keeps the thread persistent.
    This topic is discussed in the following post on the Technical Support blog:
    https://blogs.pcsoft.fr/fr/thread-persistant-tache-arriere-plan-solution-retenir-action-Background-application-android/281474976710897/read.awp.
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: wd270android.jar
Minimum version required
  • Version 18
Comments
Click [Add] to post a comment