Project

General

Profile

updating the graphical end of a progress bar

Added by jose colmenares almost 12 years ago

Hi,

I'm calling a fortran function which may take some time to execute, and want to show a progress bar while that runs. I made a thread using boost to call the fortran function. After the thread is called, I do the following:

boost::thread thread1 = boost::thread(threadFunction,

do{

if (progress < 100.0)

progress += 23.0;

else

progress =

progressBar->setValue(progress);

if (thread1.timed_join(delay))

break;

WApplication *app = WApplication::instance();

app->triggerUpdate();

}while(true);

thread1.join();

The fortran function get's called fine, the do loop is executed, but the progress bar gets updated only after the thread is finished. I added app->triggerUpdate() after going through WUploadFile, which shows something similar to what I'm doing. I called app::enableUpdates() from the main WApplication app.

what am I missing? how do I update the progress bar? looks like I only need to update the graphical part because I'm certain the progressBar->value() is being changed.


Replies (1)

RE: updating the graphical end of a progress bar - Added by Wim Dumon almost 12 years ago

Not sure what thread is doing what here, but shouldn't you call processEvents() rather than triggerUpdate() if you implement it like this?

Also realize that you seem to be keeping the a Wt thread busy here while the compute thread is computing; this kind of defeats the purpose of starting a separate thread. Consider updating the widget tree from within the processing thread, and using server push to update the browser (that would then indeed be with triggerUpdate()). In that case, use the post() method, or the (more complex) UpdateLock mechanism.

Wim.

    (1-1/1)