I\'ve struggled for the last couple of months to come up with some clean code to report progress to a user. Everything always seems to boil down to:
ReportProgr
A fairly simple and clean way would be to create an abstract class that has a do()
method and abstract doTask() and getName() methods:
do() {
ReportProgress("Starting " + this.getName());
doTask();
ReportProgress("Finished " + this.getName());
}
Then in your tasks:
class Task1 extends Task {
getName(){return "Task 1";}
doTask() {
//do stuff here
}
}
You could then have a Task that has a doTask() method that runs do()
on a whole bunch of other tasks. This could easily be recursive, in that any Task might then run a number of sub-Tasks.