Clarification about UIUpdaterJob
Hi,
I read in some post that one solution to execute a long-running op is to use UIUpdaterJob to separate a job to background and UI jobs.
I'm not quite clear what UIUpdaterJob#schedule() does. The Javadoc explains that the schedule() method schedules an update and cancels any running update. What is the 'running update'? Is it the main thread? Or does it mean if there is any other UIUpdaterJob running, the UIUpdaterJob will be canceled and this job will start running, instead? What if I want to make sure that each UIUpdaterJob instance is finished before another one is executed?
I looked at the org.eclipse.core.runtime.Job api, and it says the schedule() method in this API schedules the job in a queue waiting to be run. In this way, it makes sure that all the Jobs are executed. Does schedule() in UIUpdaterJob and Job do the same thing?
Thanks,
Petcharat
I read in some post that one solution to execute a long-running op is to use UIUpdaterJob to separate a job to background and UI jobs.
I'm not quite clear what UIUpdaterJob#schedule() does. The Javadoc explains that the schedule() method schedules an update and cancels any running update. What is the 'running update'? Is it the main thread? Or does it mean if there is any other UIUpdaterJob running, the UIUpdaterJob will be canceled and this job will start running, instead? What if I want to make sure that each UIUpdaterJob instance is finished before another one is executed?
I looked at the org.eclipse.core.runtime.Job api, and it says the schedule() method in this API schedules the job in a queue waiting to be run. In this way, it makes sure that all the Jobs are executed. Does schedule() in UIUpdaterJob and Job do the same thing?
Thanks,
Petcharat
One answer
I'm not quite clear what UIUpdaterJob#schedule() does. The Javadoc
explains that the schedule() method schedules an update and cancels
any running update. What is the 'running update'? Is it the main
thread? Or does it mean if there is any other UIUpdaterJob running,
the UIUpdaterJob will be canceled and this job will start running,
instead? What if I want to make sure that each UIUpdaterJob instance
is finished before another one is executed?
I looked at the org.eclipse.core.runtime.Job api, and it says the
schedule() method in this API schedules the job in a queue waiting to
be run. In this way, it makes sure that all the Jobs are executed.
Does schedule() in UIUpdaterJob and Job do the same thing?
The schedule() method cancels a running update of the same UIUpdaterJob
instance if there is one. Consider this pseudo-code:
UIUpdaterJob job= ....
private void selectionChanged(SelectionChangedEvent e) {
job.schedule();
}
If 'job' is already running when schedule() is called, it will be
canceled first.
Other UIUpdateJob instances are not affected. So if you create new
instances of your UIUpdaterJob, each of them will run independently.
HTH,
Patrick,
Jazz Work Item Team