|
Re: Need reference to Display in RAP app [message #666059 is a reply to message #665751] |
Mon, 18 April 2011 20:01 |
|
Hi,
> I understand that when I need to touch UI objects from a non-UI thread,
> I need to wrap the call in a runnable provided as an argument to
> UICallBack.runNonUIThreadWithFakeContext().
That's not true. If you need to access widgets from any thread that is
not the UI thread of this widget's display, you have to wrap the call in
a runnable and hand it over to Display#asyncExec(). The code will be
executed in the next request.
The method you mentioned is only needed when you have to run non-UI code
in a background thread that requires access to the session context, e.g.
when accessing a session singleton.
If you're accessing a widget, you can always get the reference to the
display by calling Widget#getDisplay() on this widget. You can also get
the display from the workbench by calling IWorkbench#getDisplay().
> So how do I get a reference to the Display? The only thing I found that
> works is to create a static accessor to it in my entry point bundle,
> where the Display is created and then used to create the workbench.
Beware! Every user session has its own display. So if you want to serve
more than a single user with your application, you must not keep any
session specific state in a static field.
Does this help?
Regards, Ralf
--
Ralf Sternberg
Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/
Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
|
|
|
|
Powered by
FUDForum. Page generated in 0.04331 seconds