Difference between revisions of "FAQ How can I track the lifecycle of jobs?"

From Eclipsepedia

Jump to: navigation, search
m
 
Line 1: Line 1:
 
It is quite simple to find out when jobs, including those owned by others, are scheduled, run, awoken, and finished. As with many other facilities in the Eclipse Platform, a simple listener suffices:
 
It is quite simple to find out when jobs, including those owned by others, are scheduled, run, awoken, and finished. As with many other facilities in the Eclipse Platform, a simple listener suffices:
 
<pre>
 
<pre>
   IJobManager manager = Platform.getJobManager();
+
   IJobManager manager = Job.getJobManager()
 
   manager.addJobChangeListener(new JobChangeAdapter() {
 
   manager.addJobChangeListener(new JobChangeAdapter() {
 
         public void scheduled(IJobChangeEvent event) {
 
         public void scheduled(IJobChangeEvent event) {

Latest revision as of 16:35, 27 March 2012

It is quite simple to find out when jobs, including those owned by others, are scheduled, run, awoken, and finished. As with many other facilities in the Eclipse Platform, a simple listener suffices:

   IJobManager manager = Job.getJobManager()
   manager.addJobChangeListener(new JobChangeAdapter() {
        public void scheduled(IJobChangeEvent event) {
            Job job = event.getJob();
            System.out.println("Job scheduled: " + job.getName());
        }
   });

By subclassing JobChangeAdapter, rather than directly implementing IJobChangeListener, you can pick and choose which job change events you want to listen to. Note that the done event is sent regardless of whether the job was cancelled or failed to complete, and the result status in the job change event will tell you how it ended.

[edit] See Also:


This FAQ was originally published in Official Eclipse 3.0 FAQs. Copyright 2004, Pearson Education, Inc. All rights reserved. This text is made available here under the terms of the Eclipse Public License v1.0.