3 Mar 2008 11:24
Updating a CAPI GUI during phases of heavy computation
Edi Weitz <edi <at> agharta.de>
2008-03-03 10:24:26 GMT
2008-03-03 10:24:26 GMT
[Attention: Running this test code might lock up your Lisp image!] I have an application with a somewhat complicated GUI from which you can start a heavy computation. What I want is that the intermediate results of the computation are reported in the main interface while a little window pops up which shows the overall progress and also provides a button to stop the computation. The attached code is a gross simplification of the actual situation, but it should hopefully be enough to illustrate my problem. My first approach was to just do it in a straightforward way. Update the GUI whenever there's a reason to update it. That's what you get if you run (TEST). If you do that, the progress window is updated, but the "main" window is kind of dead - try to move the progress window around and you'll note that the main window isn't repainted. Not good. So I thought that this happened because the heavy computation runs in the thread of the main window and prevents it from taking care of windoing events. The next thing I tried was equivalent to (TEST :SEPARATE-THREAD T). If I try this, everything locks up, no progress is reported at all. If you're lucky, you can find the "worker" process in the Process Browser and kill it. Hmmm. I tend to think that this wouldn't happen (see previous discussions), if we had real SMP. Anyway, I tried a third solution. That'd be (TEST :WAIT T). In this case, the computation thread actually waits until the progress window has been updated. This doesn't seem like an ideal solution to me as it kind of serializes the events and takes all the fun out of multi-threading, but at least it works. More or less, that is, as the whole computation now has to(Continue reading)
RSS Feed