Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » How to force something into the UI thread
How to force something into the UI thread [message #333992] Thu, 15 January 2009 12:14 Go to next message
Eclipse UserFriend
Originally posted by: szchaler.acm.org

Hi,

I am using DebugUITools.launch to trigger a certain launch configuration
programmatically. All is well, but sporadically I get a
NullPointerException from the DebugUITools.launchInBackground call.
Honestly, I have no idea how it would even get to the point of the
exception, because that should only ever be reached if there are any
build jobs around and I am trying to make very sure there aren't by
joining those before calling launch, but still...

In the javadoc for DebugUITools.launch I read that this method should be
called from the UI thread. So, currently I am working on the assumption
that hopefully my problems will be gone if I can ensure that the call is
executed in the UI thread. I've read in a different thread in this group
that there is no way to find out if I am in the UI Thread. But is there,
maybe, a way to force something into the UI thread? Can I, e.g.,
schedule a Job or Runnable to be executed within the UI thread?

Many thanks in advance for any pointers,

Steffen

--
Dr. rer. nat. Steffen Zschaler
Senior Research Associate

Lancaster University
Lancaster, United Kingdom

Email szschaler@acm.org
Phone +44 (01524) 510354
WWW http://www.steffen-zschaler.de/

--
Consider submitting to ECMDA-FA 2009, the 5th European Conference on
Model-Driven Architecture Foundations and Applications.
http://www.ecmda-fa.org/

Consider submitting to QoSA 2009, the 5th International Conference on
the Quality of Software-Architectures.
http://qosa.ipd.uka.de/

Consider submitting to MiSE 2009, the 3rd International Workshop on
Models in Software Engineering
http://wikiserver.sse.cs.tu-bs.de/mise09
Re: How to force something into the UI thread [message #333996 is a reply to message #333992] Thu, 15 January 2009 13:40 Go to previous messageGo to next message
Ed Merks is currently online Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Steffen,

Display.syncExec,which can deadlock, and Display.asyncExec are useful.
One way to get the display is with Disply.getDefault()...


Steffen Zschaler wrote:
> Hi,
>
> I am using DebugUITools.launch to trigger a certain launch
> configuration programmatically. All is well, but sporadically I get a
> NullPointerException from the DebugUITools.launchInBackground call.
> Honestly, I have no idea how it would even get to the point of the
> exception, because that should only ever be reached if there are any
> build jobs around and I am trying to make very sure there aren't by
> joining those before calling launch, but still...
>
> In the javadoc for DebugUITools.launch I read that this method should
> be called from the UI thread. So, currently I am working on the
> assumption that hopefully my problems will be gone if I can ensure
> that the call is executed in the UI thread. I've read in a different
> thread in this group that there is no way to find out if I am in the
> UI Thread. But is there, maybe, a way to force something into the UI
> thread? Can I, e.g., schedule a Job or Runnable to be executed within
> the UI thread?
>
> Many thanks in advance for any pointers,
>
> Steffen
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: How to force something into the UI thread [message #334003 is a reply to message #333996] Thu, 15 January 2009 15:25 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: szchaler.acm.org

Thanks, Ed, for the quick reply. It seems one can even use
Display.getCurrent() to find out if one is in a UI thread or not...

Steffen

Ed Merks wrote:
> Steffen,
>
> Display.syncExec,which can deadlock, and Display.asyncExec are
> useful. One way to get the display is with Disply.getDefault()...
>
>
> Steffen Zschaler wrote:
>> Hi,
>>
>> I am using DebugUITools.launch to trigger a certain launch
>> configuration programmatically. All is well, but sporadically I get a
>> NullPointerException from the DebugUITools.launchInBackground call.
>> Honestly, I have no idea how it would even get to the point of the
>> exception, because that should only ever be reached if there are any
>> build jobs around and I am trying to make very sure there aren't by
>> joining those before calling launch, but still...
>>
>> In the javadoc for DebugUITools.launch I read that this method should
>> be called from the UI thread. So, currently I am working on the
>> assumption that hopefully my problems will be gone if I can ensure
>> that the call is executed in the UI thread. I've read in a different
>> thread in this group that there is no way to find out if I am in the
>> UI Thread. But is there, maybe, a way to force something into the UI
>> thread? Can I, e.g., schedule a Job or Runnable to be executed within
>> the UI thread?
>>
>> Many thanks in advance for any pointers,
>>
>> Steffen
>>

--
Dr. rer. nat. Steffen Zschaler
Senior Research Associate

Lancaster University
Lancaster, United Kingdom

Email szschaler@acm.org
Phone +44 (01524) 510354
WWW http://www.steffen-zschaler.de/

--
Consider submitting to ECMDA-FA 2009, the 5th European Conference on
Model-Driven Architecture Foundations and Applications.
http://www.ecmda-fa.org/

Consider submitting to QoSA 2009, the 5th International Conference on
the Quality of Software-Architectures.
http://qosa.ipd.uka.de/

Consider submitting to MiSE 2009, the 3rd International Workshop on
Models in Software Engineering
http://wikiserver.sse.cs.tu-bs.de/mise09
Re: How to force something into the UI thread [message #334066 is a reply to message #334003] Sat, 17 January 2009 20:06 Go to previous messageGo to next message
Nicolas Bihan is currently offline Nicolas BihanFriend
Messages: 49
Registered: July 2009
Member
You should consider too :

PlatformUI.getWorkbench().getDisplay()

From Javadoc :

"Returns the display for this workbench.

Code should always ask the workbench for the display rather than rely on
Display.getDefault().

Returns:
the display to be used for all UI interactions with this workbench"


Nicolas Bihan

Steffen Zschaler a écrit :
> Thanks, Ed, for the quick reply. It seems one can even use
> Display.getCurrent() to find out if one is in a UI thread or not...
>
> Steffen
>
> Ed Merks wrote:
>> Steffen,
>>
>> Display.syncExec,which can deadlock, and Display.asyncExec are
>> useful. One way to get the display is with Disply.getDefault()...
>>
>>
>> Steffen Zschaler wrote:
>>> Hi,
>>>
>>> I am using DebugUITools.launch to trigger a certain launch
>>> configuration programmatically. All is well, but sporadically I get a
>>> NullPointerException from the DebugUITools.launchInBackground call.
>>> Honestly, I have no idea how it would even get to the point of the
>>> exception, because that should only ever be reached if there are any
>>> build jobs around and I am trying to make very sure there aren't by
>>> joining those before calling launch, but still...
>>>
>>> In the javadoc for DebugUITools.launch I read that this method should
>>> be called from the UI thread. So, currently I am working on the
>>> assumption that hopefully my problems will be gone if I can ensure
>>> that the call is executed in the UI thread. I've read in a different
>>> thread in this group that there is no way to find out if I am in the
>>> UI Thread. But is there, maybe, a way to force something into the UI
>>> thread? Can I, e.g., schedule a Job or Runnable to be executed within
>>> the UI thread?
>>>
>>> Many thanks in advance for any pointers,
>>>
>>> Steffen
>>>
>
Re: How to force something into the UI thread [message #334072 is a reply to message #334066] Mon, 19 January 2009 09:50 Go to previous message
Eclipse UserFriend
Originally posted by: szchaler.acm.org

Many thanks for the pointer. I've adjusted my code accordingly.

Regards,

Steffen

Nicolas Bihan wrote:
> You should consider too :
>
> PlatformUI.getWorkbench().getDisplay()
>
> From Javadoc :
>
> "Returns the display for this workbench.
>
> Code should always ask the workbench for the display rather than rely
> on Display.getDefault().
>
> Returns:
> the display to be used for all UI interactions with this workbench"
>
>
> Nicolas Bihan
>
> Steffen Zschaler a écrit :
>> Thanks, Ed, for the quick reply. It seems one can even use
>> Display.getCurrent() to find out if one is in a UI thread or not...
>>
>> Steffen
>>
>> Ed Merks wrote:
>>> Steffen,
>>>
>>> Display.syncExec,which can deadlock, and Display.asyncExec are
>>> useful. One way to get the display is with Disply.getDefault()...
>>>
>>>
>>> Steffen Zschaler wrote:
>>>> Hi,
>>>>
>>>> I am using DebugUITools.launch to trigger a certain launch
>>>> configuration programmatically. All is well, but sporadically I get
>>>> a NullPointerException from the DebugUITools.launchInBackground
>>>> call. Honestly, I have no idea how it would even get to the point
>>>> of the exception, because that should only ever be reached if there
>>>> are any build jobs around and I am trying to make very sure there
>>>> aren't by joining those before calling launch, but still...
>>>>
>>>> In the javadoc for DebugUITools.launch I read that this method
>>>> should be called from the UI thread. So, currently I am working on
>>>> the assumption that hopefully my problems will be gone if I can
>>>> ensure that the call is executed in the UI thread. I've read in a
>>>> different thread in this group that there is no way to find out if
>>>> I am in the UI Thread. But is there, maybe, a way to force
>>>> something into the UI thread? Can I, e.g., schedule a Job or
>>>> Runnable to be executed within the UI thread?
>>>>
>>>> Many thanks in advance for any pointers,
>>>>
>>>> Steffen
>>>>
>>

--
Dr. rer. nat. Steffen Zschaler
Senior Research Associate

Lancaster University
Lancaster, United Kingdom

Email szschaler@acm.org
Phone +44 (01524) 510354
WWW http://www.steffen-zschaler.de/

--
Consider submitting to ECMDA-FA 2009, the 5th European Conference on
Model-Driven Architecture Foundations and Applications.
http://www.ecmda-fa.org/

Consider submitting to QoSA 2009, the 5th International Conference on
the Quality of Software-Architectures.
http://qosa.ipd.uka.de/

Consider submitting to MiSE 2009, the 3rd International Workshop on
Models in Software Engineering
http://wikiserver.sse.cs.tu-bs.de/mise09
Previous Topic:search results vs. plugin.xml
Next Topic:Z-Order of Windows
Goto Forum:
  


Current Time: Fri Apr 19 09:12:57 GMT 2024

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

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

Back to the top