help on status manager and (a)syncExec [message #555997] |
Mon, 30 August 2010 10:01  |
Eclipse User |
|
|
|
Hi all,
in my rcp application I've got the following call chain:
MyTableViewer -> MyContentProvider -> MyDao.loadElementsFromDatabase()
so each time the table view is created and displayed, it asks the content provider to provide the content, and the latter asks to a DAO to load the data from the database. I'd like to notify the user about what is happening within the DAO logic, so I created a wrapper for a status line manager that is used directly from within the DAO thru the following method:
public void setMessage(final String message) {
PlatformUI.getWorkbench().getDisplay().syncExec( new Runnable(){
public void run() {
statusLineManager.setMessage(message);
}
});
}
The problem is that the message is never displayed and a little debugging shows that the thread that is executing the statusLineManager.setMessage(message); is the "main" thread, is this correct? How can I get the status line displaying messages from the DAO in sync?
Thanks.
|
|
|
|
|
|
|
|
|
|
|
|
Re: help on status manager and (a)syncExec [message #632815 is a reply to message #632766] |
Thu, 14 October 2010 06:45  |
Eclipse User |
|
|
|
On 14.10.2010 10:33, Luca Ferrari wrote:
> However, now that I guess I've understood the asyncExec a little more,
> does it make sense to use a thread to load the elements and execute a
> runnable instead of using a Job scheduled immediately?
I think the basic guide-line should be:
1) If you need to interact with the UI, use asyncExec
2) If your work has considerable parts that are UI-independent, use
a job for this. You will run in problematic situations, when
you have several dependent work units of the form
UI -> non-UI -> UI -> non-UI ->...
etc. If possible, try to isolate UI and non-UI work-units in as large
blocks as possible to prevent the overhead of an unnecessary high
number of context switching.
UIJob is somewhat in-between. I use it only, if I need to.
HTH & Greetings from Bremen,
- Daniel
|
|
|
Powered by
FUDForum. Page generated in 0.04669 seconds