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 Go to next message](theme/Solstice/images/down.png) |
Eclipse User![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=) |
|
|
|
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 message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Ed Merks![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=ed.merks%40gmail.com) Messages: 33205 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 message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Eclipse User![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=) |
|
|
|
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 message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Nicolas Bihan![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=n.bihan%40itnsa.com) 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 Go to previous message](theme/Solstice/images/up.png) |
Eclipse User![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=) |
|
|
|
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
|
|
|
Goto Forum:
Current Time: Sat Aug 31 23:24:01 GMT 2024
Powered by FUDForum. Page generated in 0.03158 seconds
|