I am performing a read/write operation within a function that usually takes around 2 seconds to complete. During this, I need to update certain labels and such using current values within the function. Normally, the UI wouldn't update until the function was complete, but this was remedied with Application.DoEvents in the loop, which allowed the labels and such to update during the long loop.

However, my client wants me to have a progress bar showing the current progress and how much time is remaining. I have no problem getting the % complete and changing the value of the progress bar each iteration, but for some reason, the progress bar is not updating until the end of the entire operation, which means it goes from 0 to 100 in one swoop.

I don't see why this sort of thing is happening because I am setting the value just like with all the labels, and I am still calling Application.DoEvents. I have tried using a BackgroundWorker, threads, Invoke, and everything of that nature, but cannot, for the life of me, get that darned progress bar to update during the loop.

Here is my entire function, which, I know looks messy, as I am just trying to get things to work now, and then going to fix it up later:

http://rafb.net/p/Tqo5uL10.html