What is the proper way to use progress monitors for an Eclipse Job that schedules and joins on another Eclipse job? I’d like the subtask to be associated with the main task.
Ideally, I’d like to be able to tell the subtask to run with a SubProgressMonitor created from the main monitor, however I don’t see a way to do this. I’ve looked at the Job.setProgressGroup(..., ...) method, but the documentation indicates that the group should be created with IJobManager.createProgressGroup().
Here’s a code snippet for context:
@Override
protected IStatus run(final IProgressMonitor monitor) {
try {
monitor.beginTask("My Job A", 100);
MyJobB subtask = new MyJobB();
// how how should subtask's progress be tracked?
subtask.schedule();
subtask.join();
return Status.OK_STATUS;
} catch (Exception ex) {
// return error status
} finally {
monitor.done();
}
}
To answer the original question – you can do it this way:
It’s a bit more elegant, if you create the progress group externally:
Please note that a Job that is not scheduled yet will be displayed as “finished”:
If possible I would consider merging the two Jobs and using a SubMonitor.