Extended or New TurboVision Objects
Q. 406 Can I use the Idle method to do background processing?
Certainly.
- A idea, borrowed from Xt (X Intrinsics Toolkit), for general background processing is:
- you have a collection with far pointers to boolean functions
- add functions to this collection if you need a certain background task to start
- when Idle is called it does the following things
- if the collectionis empty, do nothing
- else for each function in the collection
- execute it
- if it returns true, remove it from the list
- else retain it for the next round
I think I post code to do this in the next version of this FAQ.
- For example printing in the background involves the following steps:
- Write first to a very fast storage device, usually your local harddisk. Now your
application has finished its printing and can return to the user for doing other tasks.
- Now the Idle method comes into play. As the user gets attention again the Idle method
will be called when the user does not input anything. As even fast typers don't even approach
100 characters per second the Idle method will be called very often. Now your Idle method
can call the PrintInBackground procedure. The PrintInBackGround procedure can print for
example the first 10 characters of the file on your harddisk (if you choose to print first to your
harddisk). Then it finishes and returns to Idle. Idle returns to, your user can type something
and Idle is called again. Now the next 10 characters are printed and so on.
Your application will remain responsive and the Idle time will be
utilized efficiently. BTW, There are other and more advanced solutions
possible to the background printing issue but this is one of the
simplest.
Next question
B de Boer Last modified: Tuesday 18 April
1995 - 10:20