Progressbar is frozen with syncExec [message #1377185] |
Fri, 23 May 2014 19:23 |
mark tal Messages: 11 Registered: July 2012 |
Junior Member |
|
|
I want to display a progres bar in GUI while a time consuming task, this task collects data from gui form, so I must use
Display.getDefault().syncExec or Display.getDefault().asyncExec
in order to access GUI.
The issue with my following code, that while task is running the main GUI thread is locked and the progress bar is not "running".
Please help.
showProgress.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
try {
new ProgressMonitorDialog(shell).run(true, true, new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
monitor.beginTask("Running long running operation", IProgressMonitor.UNKNOWN);
Display.getDefault().syncExec(new Runnable() {
public void run() {
for (int i = 0; i < 0100; i += 1) {
try {
Thread.sleep(1000);
readDataFromGUI();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
});
monitor.done();
}
});
} catch (InvocationTargetException e) {
MessageDialog.openError(shell, "Error", e.getMessage());
} catch (InterruptedException e) {
MessageDialog.openInformation(shell, "Cancelled", e.getMessage());
}
}
});
[Updated on: Fri, 23 May 2014 19:51] Report message to a moderator
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02337 seconds