Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » UI Thread
UI Thread [message #333972] Wed, 14 January 2009 19:48 Go to next message
Benson Ning is currently offline Benson NingFriend
Messages: 14
Registered: July 2009
Junior Member
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 #333978 is a reply to message #333972] Thu, 15 January 2009 08:03 Go to previous messageGo to next message
Danail Nachev is currently offline Danail NachevFriend
Messages: 110
Registered: July 2009
Senior Member
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!
>
Re: UI Thread [message #334004 is a reply to message #333978] Thu, 15 January 2009 15:26 Go to previous message
Eclipse UserFriend
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
Previous Topic:How to wait for launches to finish
Next Topic:Package Explorer shows no CVS infos after cvs-plugin was updated
Goto Forum:
  


Current Time: Fri Apr 26 15:24:23 GMT 2024

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

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

Back to the top