| [news.eclipse.platform.swt] Re: Halting SWT thread but repainting |
Just for the archive - here is the solution: use Shell.setEnabled(false) to block it while the Swing process is running. This will reject any use input but still handle repaint events.
Hans,
So a pattern such as the following can be employed (from SWT thread, assuming there is a boolean field "busy" in the class):
SwingUtilities.invokeLater(new Runnable() {
public void run() {
try {
// Do the Swing work, e.g. modal dialog
}
finally {
busy = false;
}
}
});
shell.setEnabled(false);
Display display = shell.getDisplay();
while (!shell.isDisposed() && busy) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
shell.setEnabled(true);
Hans