Board index » cppbuilder » multithreading and offtime precalculations
François Charton
![]() CBuilder Developer |
multithreading and offtime precalculations2004-09-03 09:00:57 PM cppbuilder62 Hi, I have an application which, at times, does a fairly large number of precalculations when the program is launched. On slow machines, it can take a fairly long time (up to a few minutes in some cases), which means displaying a splash screen for a long time, and confusing the user (and making the application look dumb). The sad part is that most of these calculations are related to very specific parts of the program, which are not often used by average users. So, I was thinking of using a separate thread to have things calculated while the app is idle. The program would then launch very quickly, let the user work with the parts of the application which do not use precalculation, eventually waiting for them to finish when he needs them. To do so, I need to have a simple way to check whether some part of the precalculation is finished (so that the main app "knows" if some operation can be done), and, if not, to signal that it is finished, so that the main program can wait for it, given that the precalculation procedure consists in several steps, and that I don't want to wait for the slowest one to finish. Summarizing, it means : 1- launching a separate calculation thread which does the precalculation while the app is idle (it might even not imply a separate thread, but just a clever use the OnIdle handler), 2- let it signal that some part of the calculation is finished 3- have a simple way to test these signals in my main application, and wait for them when needed (either by disabling "temporarily unavailable" commands, or having such commands, wait for the signal...) Actually, maybe it does not even imply several threads, but a clever use of on_idle messages... Now, once the problem is posed, I am a bit lost on where to start from... Can anyone give me some directions ? TIA Francois |