Project

General

Profile

Progress bar not appearing till end of process. A threading issue?

Added by John Davidson over 10 years ago

I have a function that basically looks like this:

progressbar.show()
while more stuff to do
   do stuff
   if 5 per cent progress increment
      progressbar.setvalue()
   end if
end loop
progressbar.hide()

but the progress bar doesn't appear until the very end, when it's already 100 per cent finished. (I can only see that if I comment out the last progressbar.hide(). Otherwise the show() and the hide() seem to arrive at the same time, and it never really appears at all.)

Do while loops get spun out as some sort of asynchronous thread in Wt/c? Am I just out of threads and the app is waiting for a thread to be made available? Or could it just be the UI isn't updating as fast as I might like? (I put in a limit to the number of progressbar updates, so it only updates it once every 5 per cent, but it didn't help.)

Whatever it is, how do I force the progress bar to appear and update in real time?

I'm none too good with threads, as you can tell from my question.

thanks in advance

John


Replies (1)

RE: Progress bar not appearing till end of process. A threading issue? - Added by John Davidson over 10 years ago

Solved it!

After progressbar.setvalue() I added wt::wapplication::processEvents() (or actually this->processEvents() since I was in the wapplication already) to force the UI to display the changes.

It slows the app down if I update a lot, but I found that by minimising the number of updates to only once every 5% increment, it barely slows the app down.

    (1-1/1)