Say I have a button: btnExecute
This button executes all these methods:
doAction1();
doAction2();
doAction3();
doAction4();
Each of these actions takes a couple of seconds.
How would I go about updating a progress bar as each of these methods are run?
I know I could go into each of them and just add pbExecuteProgress.value = 10 for example but I feel like there must be a better way to do this.
I also do not want to do something like this:
doAction1();
pbExecuteProgress.value = 30
doAction2();
pbExecuteProgress.value = 60
doAction3();
pbExecuteProgress.value = 80
doAction4();
pbExecuteProgress.value = 100
Is there ANY way I create a progress bar that goes up to 100 in value and is = to the progress of a method??
if you wanted to customize the progress values:
Declaration and creation of the collection of actions does not have to happen just before you loop through it. In fact, a strength of this pattern (a form of the Strategy pattern) is that new Actions can come from anywhere, both inside the current class and out.