If you have a good estimate of how long the operation will take then you may update the progress bar using a timer (
There are many examples[
^]).
A better alternative is executing the time-consuming operations on separate threads and update the progress bar from the threads themselves (
examples[
^]).
Of course you can re-use the same progress bar for showing the progress of different operations.