Current UI update is always triggered by the next UI event [message #552124] |
Tue, 10 August 2010 19:48 |
Eclipse User |
|
|
|
Hi,
I have a background job to load stuff from the database and update the TreeViewer. The scenario of the background job is
1. a TreeItem is expanded
2. loads data from DB
3. updated the UI by populating the children of the TreeItem using Display.async
It is pretty much similar to the background job example from here http://wiki.eclipse.org/RAP/FAQ#How_to_update_the_UI_from_a_ background_thread_using_Jobs.3F
In Safari and Opera, the UI is not refreshed (#3) until the next UI event comes, e.g., clicking any other widget to trigger the next UI event. In the debug mode, I saw that the body of the Runnable from Display.async is not executed until the next event comes. Even if I manually execute Display.readAndDispatch, it fails to execute the current UI update. The current UI update is always triggered by the next UI event. Here is what the code looks like:
private class ResourceLoadingJob extends Job {
...
private void loadResource() {
// running get children in session;
UICallBack.runNonUIThreadWithFakeContext(display, new Runnable() {
@Override
public void run() {
// load the resource with session on
}
});
display.asyncExec(new Runnable() {
@Override
public void run() {
try {
if (!treeViewer.getControl().isDisposed()) {
treeViewer.refresh(resource, true);
}
} catch (Exception e) {
// handle exception
}
}
});
This issue doesn't happen on other browsers. I am wondering how can I fix it? It looks like a defect in RAP's UI update thread which sleeps and forgets about the UI update.
Thanks,
Owen
|
|
|
Powered by
FUDForum. Page generated in 0.03411 seconds