[SOLVED]Accessing GUI from another thread with progressbar [message #1374155] |
Thu, 22 May 2014 13:54 |
mark tal Messages: 11 Registered: July 2012 |
Junior Member |
|
|
I have a method that collects data from GUI composites, does some logic and then updates GUI again.
While this is done, i want to display a progress bar.
This is my code:
ProgressMonitorDialog dialog = new ProgressMonitorDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
try {
dialog.run(true, false, new IRunnableWithProgress() {
public void run(final IProgressMonitor monitor) {
monitor.beginTask("Progress", IProgressMonitor.UNKNOWN);
Job job = new Job("Job") {
@Override
protected IStatus run(IProgressMonitor arg0) {
Display.getDefault().asyncExec(new Runnable() {
public void run() {
for (int i = 0; i < 1000; i++) {
try {
doTask();
}
}
});
return Status.OK_STATUS;
}
};
job.schedule();
try {
job.join();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
monitor.done();
}
The first issue, the code doesn't block on job.join();
How to fix?
Update:
job.getResult() = isOK()
and job is still running in background but doesn't block at job.join();
[Updated on: Fri, 23 May 2014 19:24] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.02843 seconds