So I'm working on adding a progress bar to my app, and I have all the variables created to track the progress of a download, but when I try to edit the variables in a while loop they do not update until after the loop is finished. Below is a list of what happens.
Download function begins
I set the total bytes to the file size
I set the current bytes to 0
While loop begins
I add 1 for each byte that is copied
After 1 million bytes are copied I call the code below
I print the current bytes and it displays the correct number
I call the repaint function
Inside the paint function I print the current bytes and it displays 0
loop ends
download function ends
paint function is called later
The print inside the paint function now shows the total current bytes were downloaded
Does anyone know why the paint function is not reading the real value set in the loop until after the loop is over, and if so how do i fix this problem?