UI Thread [message #333972] |
Wed, 14 January 2009 14:48  |
Eclipse User |
|
|
|
Hi,
I have code needs to determine if the current thread is UI thread or not,
since my plugin can not depend on any UI plugins, so I can not use
Display.getCurrent() to do so, is there any other way I can check the
thread? Will the UI thread in eclipse has higher priority?
Thanks for your help!
|
|
|
|
Re: UI Thread [message #334004 is a reply to message #333978] |
Thu, 15 January 2009 10:26  |
Eclipse User |
|
|
|
Originally posted by: szchaler.acm.org
Couldn't you just check Display.getCurrent(). The javadoc seems to say
that if it returns null you are not a UI thread...
Steffen
Danail Nachev wrote:
> UI Thread is not distinguishable from the other threads, so you cannot
> determine easily whether the current thread is an UI thread.
>
> The uber hardcore hack would be to examine the call stack and check
> whether SWT classes or on it. In this case, there is a great chance that
> you are on the UI thread.
>
> But I suggest that you rethink your strategy and modify your code to not
> depend on the UI thread or pass this information somehow from other
> code, which depends on UI classes.
>
> Benson Ning wrote:
>
>> Hi,
>>
>> I have code needs to determine if the current thread is UI thread or
>> not, since my plugin can not depend on any UI plugins, so I can not use
>> Display.getCurrent() to do so, is there any other way I can check the
>> thread? Will the UI thread in eclipse has higher priority?
>>
>> Thanks for your help!
>>
>>
--
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
|
|
|
Powered by
FUDForum. Page generated in 0.09074 seconds