The introduction of the true compiler for Basic4PPC opens up some avenues previously closed. One of these is the ability to write threads in Basic4PPC code rather than only being able to do this in a library.
Some/most of you will know that a thread is a separate flow of program execution. Basic4PPC normally has only one thread, the GUI (Graphical User Interface) thread that, not surprisingly, handles the user interface (and everything else). Using this library you can create additional threads that operate (apparently) in parallel alongside each other and the GUI thread.
Threads can be useful to keep the user interface alive while performing a long sequence of computations. For instance my Flite speech dll for the device runs on the GUI thread and while it is speaking you can't do anything else. Included is an example of running it on a thread so you can set it off and leave it to run and carry on user interaction. You need FliteDevice.dll and fliteDLL.dll in the app folder on the device.
Speech library for the DEVICE!
Compile ThreadTestDevice.sbp optimised for device with FliteDevice.dll and Threading.dll in the desktop app folder and transfer the resulting exe and Threading.dll to the device app folder.
The library protects itself if it finds itself running in a legacy mode so hopefully you can't crash your app whilst playing! I'll produce a help with more info later. However there is a load of comment in the ThreadTest app to hopefully give you enough information to try it out - should you dare!
EDIT :-I've updated demo source as per dzt comment below. Also I just noticed a minor issue in my workarounds to issue warnings when running in legacy mode (where it doesn't work anyway). I don't quite understand the problem at the moment but it doesn't really matter as it is cosmetic really. Just shows you can't do enough testing before release
EDIT :- Update to version 1.1 to warn politely (as always intended) rather than throw an error when any of the RunLocked calls were used in legacy mode.
EDIT : - Updated to 1.2 with Process object added.
EDIT : - Updated to 1.3 with support for module name prefixes for the thread Sub. Help and source included. Demo sources are in 6.50 format but the library is compatible with all Basic4ppc 6.xx releases.
EDIT : - Updated to 1.4. See post #39 for details.
EDIT : - Updated to 1.5 for a bug fix. See post #46 for details
THIS LIBRARY IS REPLACED BY http://www.b4x.com/forum/additional-libraries/4805-threading-library-version-2-a.html#post27720
Some/most of you will know that a thread is a separate flow of program execution. Basic4PPC normally has only one thread, the GUI (Graphical User Interface) thread that, not surprisingly, handles the user interface (and everything else). Using this library you can create additional threads that operate (apparently) in parallel alongside each other and the GUI thread.
Threads can be useful to keep the user interface alive while performing a long sequence of computations. For instance my Flite speech dll for the device runs on the GUI thread and while it is speaking you can't do anything else. Included is an example of running it on a thread so you can set it off and leave it to run and carry on user interaction. You need FliteDevice.dll and fliteDLL.dll in the app folder on the device.
Speech library for the DEVICE!
Compile ThreadTestDevice.sbp optimised for device with FliteDevice.dll and Threading.dll in the desktop app folder and transfer the resulting exe and Threading.dll to the device app folder.
The library protects itself if it finds itself running in a legacy mode so hopefully you can't crash your app whilst playing! I'll produce a help with more info later. However there is a load of comment in the ThreadTest app to hopefully give you enough information to try it out - should you dare!
EDIT :-I've updated demo source as per dzt comment below. Also I just noticed a minor issue in my workarounds to issue warnings when running in legacy mode (where it doesn't work anyway). I don't quite understand the problem at the moment but it doesn't really matter as it is cosmetic really. Just shows you can't do enough testing before release
EDIT :- Update to version 1.1 to warn politely (as always intended) rather than throw an error when any of the RunLocked calls were used in legacy mode.
EDIT : - Updated to 1.2 with Process object added.
EDIT : - Updated to 1.3 with support for module name prefixes for the thread Sub. Help and source included. Demo sources are in 6.50 format but the library is compatible with all Basic4ppc 6.xx releases.
EDIT : - Updated to 1.4. See post #39 for details.
EDIT : - Updated to 1.5 for a bug fix. See post #46 for details
THIS LIBRARY IS REPLACED BY http://www.b4x.com/forum/additional-libraries/4805-threading-library-version-2-a.html#post27720
Attachments
Last edited: