Normally when a Job
is running, it is necessary to periodically update the user to let them know the state of progress. By default, if a Job
provides no information, a generic busy
indicator is shown. When a Job
is executed, it is passed an IProgressMonitor
object, which can be used to notify the user of progress (and provide a way to cancel the operation). A progress monitor has a number of tasks, each of which has a total unit of work that it can do. For jobs that don't have a known amount of work, UNKNOWN
can be specified and it will be displayed in a generic busy
indicator.
Open the
HelloHandler
and go to theexecute()
method. In therun()
method of the innerJob
, add abeginTask()
at the beginning, and aworked()
method in the loop after each second's sleep, for five iterations. The code will look like the following:protected IStatus run(IProgressMonitor monitor) { try { monitor.beginTask("Preparing", 5000); for(int i=0;i<5;i++) { ...