A character string to be used as the name of the thread. This thread name must be unique among all currently running threads. There will always be a thread named "Main" running, so you cannot use this name.
The string of code that should be run in this background thread.
A pointer to a namespace you would like to use as the context for the thread. This is similar to passing pVariables into a UDF and then using with pVariables ... end with.
Create a thread - requires a unique thread name , code to run - allows for 'base' variable frame to be passed in.
The THREAD_CREATE() function creates a new thread.
thread_create("mythread", <<%code% while flag_run ' do a bunch of stuff end while %code%)
Then when you want to stop the thread, you can do the following from another script, the interactive window, etc:
tv = thread_variables("mythread") tv.flag_run = .f. delete tv
The following script removes unwanted temporary files. This thread works at the lowest priority.
function RaysCleanup as V() thread_create(thread_name_create("Ray's cleanup"),<<%code% dim self as P dim files as C self = thread.current() self.set_priority(-2) files = filefind.get(a5.Get_private_Path() + chr(92) + "$$*.*",0,"pn") *for_each(x,file.remove(x),files) files = filefind.get(a5.Get_private_Path() + chr(92) + "*.pdf",0,"pn") *for_each(x,file.remove(x),files) files = filefind.get(a5.get_path() + chr(92) + "$$*.*",0,"pn") *for_each(x,file.remove(x),files) %code%) end function
Desktop applications only.