Background download Thread Progress Windows problem

As a test (and only a test) try putting this in after you increment the progress value:

MessageManager::getInstance()->runDispatchLoopUntil (200);

Rail

The problem is you probably have not initialized ā€˜progress = 0’. Then you’re adding values to ā€˜progress’ in the run() but until ā€˜progress’ reaches 1% you will wait for eternity.

Edit: Ah, sorry, I see it’s in the constructor. I’ve got almost identical code in my apps and it works perfectly fine.

progress += i / j;

maybe you meant

progress = i / j;

Shouldnā€˜t i be converted to float first before dividing? Otherwise it will return 0 al the time. Or am I wrong here?

Edit: sorry, j is double so never mind :wink:

Personally I’d have written it with an explicit cast to double, just to make sure that’s clear to a reader, e.g.

progress = currentItem / (double) totalNumItems;
1 Like

I think it was clear to reader, i was testing with hardcoded values also.
MessageManager::getInstance()->runDispatchLoopUntil (200);
works for testing in simple loop, but returns assertion when running in thread as it is not a Message thread.