`
lizhensan
  • 浏览: 371104 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

rcp 在耗时操作中添加 进度条

阅读更多
使用场景:一般在比较耗时的操作中添加该功能,更友好的操作。
实现步骤
1:窗口精度条对话框
ProgressMonitorDialog prog = new ProgressMonitorDialog(getShell());

2:prog.run(true, false, new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) {
monitor.beginTask(精度条上的提示信息....", IProgressMonitor.UNKNOWN);
。。。。这里是你操作。。。。。
monitor.done();
}
});


prog.run(true, false, new IRunnableWithProgress())
第一个参数
表示 action 的处理是脱离 UI 主线程的,因此 action 必须使用 Display.syncExec(Runnable) 或者 Display.asyncExec (Runnable) 来进行 drawing 。

第二个参数表示 是否可以取消该操作。
第三个  操作 就是真正执行操作的线程。


参考 http://hi.baidu.com/monkeyhoop/blog/item/52fd6e5508533752574e0002.html
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics