Job job = new Job()
{
public boolean needsExecute()
{
return true;
}
public void execute(ProgressStatus progressStatus) throws Exception
{
// Do necessary work in the session.
}
public void finished()
{
// Cleanup after job is finished.
}
public String getName()
{
return "My Job";
}
};
IdleJobService.getInstance().addJob(job);
// Remove the job when it is no longer necessary.
IdleJobService.getInstance().removeJob(job);