我遇到这样的情况,一旦项目复制完成,它就必须更改用户界面。我创建了一个作业来复制项目并加入作业,以便在其完成之前不会修改用户界面。但 ui 被挂起,直到复制操作完成。这是我的代码
private void copyItems(SelectDTO selection, TreeViewer viewer) {
try {
Job job = new Job("test") {
@Override
protected IStatus run(IProgressMonitor monitor) {
ISafeRunnable runnable = new ISafeRunnable() {
@Override
public void run() throws Exception {
//copy items
}
@Override
public void handleException(Throwable exception) {
}
};
SafeRunner.run(runnable);
return Status.OK_STATUS;
}
@Override
public boolean belongsTo(Object family) {
}
};
我已加入 addJobChangeListener 中的工作
job.addJobChangeListener(new IJobChangeListener() {
@Override
public void sleeping(IJobChangeEvent event) {
// TODO Auto-generated method stub
}
@Override
public void scheduled(IJobChangeEvent event) {
// TODO Auto-generated method stub
}
@Override
public void running(IJobChangeEvent event) {
// TODO Auto-generated method stub
}
@Override
public void done(IJobChangeEvent event) {
}
@Override
public void awake(IJobChangeEvent event) {
// TODO Auto-generated method stub
}
@Override
public void aboutToRun(IJobChangeEvent event) {
// TODO Auto-generated method stub
}
});
job.schedule();
job.join();
} catch (Exception e) {
}
}
调用此方法后,我正在更新用户界面。我可以做哪些改变来停止用户界面的挂起?谢谢。
BIG阳
相关分类