Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » How to get onto GUI Event Thread from non UI thread...
How to get onto GUI Event Thread from non UI thread... [message #123060] Thu, 26 February 2009 05:30 Go to next message
Eclipse UserFriend
Originally posted by: michael.suwiryo.siemens.com

Hello,

In RCP application especially in Java multi-threaded application, it's very
common to execute some code on a different thread (a.k.a Thread Hop) and
then go back to UI Thread to update the UI.

Getting back to SWT Display Thread in RCP is straightforward because RCP is
only for single user and this can be done using Display.getDefault() call
which always return the right Display.

As for RAP, due to the nature of multi-user environment, there is no easy
way to go back to UI Event Thread from non UI Thread.

One possible solution is to keep passing Display reference all over the
place. But in some scenario, passing Display reference is probably not
possible.

Second possible solution is to store the Display object as part of the
HTTPSession with unique ID and then retrieve it back as necessary. The
problem with 2nd solution is that the RWT Utility class requires to be run
in UI Thread. So, this also does not work in non UI Thread case.

The desired solution here is to have true implementation of
Display.getDefault() in RAP which return the right Display based on current
user session. I understand why it may not be easy to implement this in RAP.
However, if supported, it would be easier to convert an RCP application to
RAP.

Besides the options I mention above, I was wondering if anyone has any
suggestion or pointer on how to solve this issue. Has anyone encountered
this problem?

Thanks for any pointers.

Regards,
Michael Suwiryo
Re: How to get onto GUI Event Thread from non UI thread... [message #123179 is a reply to message #123060] Thu, 26 February 2009 11:20 Go to previous messageGo to next message
Stefan Hansel is currently offline Stefan HanselFriend
Messages: 103
Registered: July 2009
Senior Member
>> One possible solution is to keep passing Display reference all over the

>> place. But in some scenario, passing Display reference is probably not
>> possible.

Why is this not possible ?
For us this is currently the only way - and working not too bad, once all
Display.getDefaults() were removed/replaced.
It's one of those things, that have to be done when migrating to a
multiuser-world.

There were some discussion earlier on how to solve this more convenient.
Unfortunately there where more cons then pros, but read yourself:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=250696

Regards,
Stefan
Re: How to get onto GUI Event Thread from non UI thread... [message #123191 is a reply to message #123179] Thu, 26 February 2009 11:35 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi,

Just an idea (I don't know if it works in RAP) better than using
Display.getDefault() one uses PlatformUI.getWorkbench().getDisplay()!

I'm never ever using Display.getDefault() in my RCP-Applications. By the
way the same is true for
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShel l() to find
the active shell (instead of Display#getActiveShell())

Tom

stefan.hansel@tolina.de schrieb:
>>> One possible solution is to keep passing Display reference all over the
>
>>> place. But in some scenario, passing Display reference is probably not
>>> possible.
>
> Why is this not possible ?
> For us this is currently the only way - and working not too bad, once all
> Display.getDefaults() were removed/replaced.
> It's one of those things, that have to be done when migrating to a
> multiuser-world.
>
> There were some discussion earlier on how to solve this more convenient.
> Unfortunately there where more cons then pros, but read yourself:
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=250696
>
> Regards,
> Stefan


--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Re: How to get onto GUI Event Thread from non UI thread... [message #123305 is a reply to message #123191] Fri, 27 February 2009 09:59 Go to previous message
Stefan Hansel is currently offline Stefan HanselFriend
Messages: 103
Registered: July 2009
Senior Member
>> Just an idea (I don't know if it works in RAP) better than using
>> Display.getDefault() one uses PlatformUI.getWorkbench().getDisplay()!

I didn't try it myself, but I doubt that this would work from a
Non-UI-Thread for the same reasons as Display.getDefault() won't work.
PlatformUI.getWorkbench() is a static call which - in a multisession world
- had determine, which of the multiple workbenches is the right.

And that's currently not possible from a Non-UI-thread.
Previous Topic:Text Widget with Style SWT.NONE
Next Topic:Rendering of TreeViewer on SashForm
Goto Forum:
  


Current Time: Tue Apr 23 17:26:23 GMT 2024

Powered by FUDForum. Page generated in 0.04161 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top