I have a dispose listener which has a Job created inside widgetDisposed(DisposeEvent event) method. So executing this method when the TreeViewer gets disposed is causing, An internal error occurred during: "Cleanup Job". No context available outside of the request service lifecycle. This code is used by both RCP and RAP, works fine on RCP app.Issue is with RAP. Can any one suggest what's going wrong with this?
private void addDisposeListener() {
treeViewer.getTree().addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent event) {
Job CleanupJob = new Job("Cleanup Job") { //$NON-NLS-1$
@Override
protected IStatus run(IProgressMonitor arg0) {
doCleanup();
return Status.OK_STATUS;
}
};
CleanupJob.setUser(false);
CleanupJob.setSystem(true);
CleanupJob.schedule();
}
});
}