![]() |
|
|||||||
| Home | Register | FAQ | Members List | Search | Today's Posts | Mark Forums Read |
| Additional Libraries Users contributed libraries. This sub-forum is only available to licensed users. |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
||||
|
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. Last edited by agraham : 10-15-2008 at 03:36 PM. Reason: Updated zip |
|
||||
|
Quote:
![]() I feel the need to say again how useful is this library, as there are many b4ppc functions taking long time to finish (FTP, Image processing etc.) and until then it is not so elegant to have the UI frozen. I also should say that I love Process object. Last edited by dzt : 01-23-2008 at 10:14 AM. |
|
||||
|
I'm about to use this lib for the first time, so before i do i need to ask just one thing...
I need to thread a timer... is this thread fired as a single sub? (timer1_tick)???
__________________
Paulo Gomes Porto, Portugal PC: Dual-Core 1,8Ghz, 2GB RAM, 80GB HD PPC: Qtek9000, 1GB SD DLL Version Listing |
|
||||
|
I am writing an "alert" progam, in wich the user will enter a series of data including a date field...
in the mean time the program ( i have thought of an "external"program...), will, twice a day, as setted by the user, check if the date entered above matches the Today date, and if true, pop-up an Alert....But it must not halt the execution... So what the best way to go?
__________________
Paulo Gomes Porto, Portugal PC: Dual-Core 1,8Ghz, 2GB RAM, 80GB HD PPC: Qtek9000, 1GB SD DLL Version Listing |
|
||||
|
Two possibilities spring to mind.
For both possibilities I would suggest using a timer with a fairly long interval to check whether it is the right time to start one of these checks then :- a) Start another timer or reset the original timer's interval to be shorter, say 500mS or so. Do the data checks in the timer code but structure the code so that it, for example, checks one set of data, saves where it has got to in one or more global variables, then exits the timer picking up the data to check the next set in the next timer tick, saving and exiting again, and so on till complete. b) Use the timer code to start a separate thread that does the checking in a long code loop without returning. If you want to display the alerts from within that code you would need to use a timer event as shown in the sample app. Alternatively you could build some global variables with the alert data and then set a global flag when the thread completes that the timer could check for and then display whatever is needed. |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Threading | Mr_Gee | Basic4ppc Wishlist | 0 | 09-23-2008 08:57 PM |
| formEXdesktop.dll and threading.dll | Byak@ | Questions & Help Needed | 5 | 08-13-2008 04:05 PM |
| Parallel Processing / Multi-Threading questions | TWELVE | Questions & Help Needed | 7 | 04-29-2008 12:40 PM |
| Error on compile with Optimising | TonyGprs | Questions & Help Needed | 4 | 01-27-2008 12:15 PM |
| The Hekkus Library doesn't work when used with the Optimized Compiler | Louis | Questions & Help Needed | 5 | 12-28-2007 09:06 PM |