If I have a progressbar in an iOS app, it doesnt seem to update inside a loop
Jumping from 0 to 100 without ever showing the interim values.
calling .refresh on the progressbar inside the loop doesn’t seem to do the trick ,and I cant find a doevents or equivalent.
How do you make a responsive progress indicator for a task that can take a few seconds?
Do the task in a thread and update the UI on the main thread?
It’s a file/save operation.
I cant do that in a thread as there is a chance that the document will be modified while it is being prepared.
On iOS, UI updates are executed when the chain of methods is completed.
Calling refresh is the same, it is only executed at the end.
You will need to use a thread if the saving is a lengthy process.
I have never seen a save file process to take more than a second, even for 2-3MB files.
Maybe the file you are creating is bigger?
If you want to prevent the user from doing anything while saving is running, display a container control above the view to prevent any taps on the screen.
The time is taken assembling an XML document which could contain 250K elements.
Its not the ‘write to disc’ time, its the ‘create a file that can be written’ time
Then I guess processing the XML in a thread is the best thing to do.
And overlaying a container to prevent user taps.