Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Confused on the subclasses of EventListener in eclipse
Confused on the subclasses of EventListener in eclipse [message #780463] Wed, 18 January 2012 06:43 Go to next message
Sai Missing name is currently offline Sai Missing nameFriend
Messages: 25
Registered: March 2011
Junior Member
Hi everyone:

I wrote an eclipse plugin, and met many "invalid thread errors". I know that this error is caused by "accessing a GUI object from a non-UI thread", but am *really* confused on the huge volume of "EventListener"s in eclipse. I was surprised to find some listeners are called from UI-thread, while others are called from non-UI thread.

For example,

AWTEventListener, IResourceChangeListener and IJobChangeListener implements the EventListener interface. However, I found the call back method in AWTEventListener is always called by UI-thread, thus the object access code there do not need to be wrapped by sync/asyncExec. However, the other two listeners (IResourceChangeListener, and IJobChangeListener) are often called by non-UI thread, if the call back there access some UI object, an invalid thread error becomes apparent.

My question is "which listeners will be called by UI/non-UI thread"? is there any rule for this? If not, do I need to remember (hardcode) those facts?

thanks

-Sai
Re: Confused on the subclasses of EventListener in eclipse [message #780532 is a reply to message #780463] Wed, 18 January 2012 13:40 Go to previous messageGo to next message
Satyam Kandula is currently offline Satyam KandulaFriend
Messages: 444
Registered: July 2009
Senior Member
If your non-UI based listener needs to call UI object, this call should happen using asyncExec or syncExec.
For the bigger part of your question, you may get a better answer in the 'Eclipse Platform' forums.
Re: Confused on the subclasses of EventListener in eclipse [message #780629 is a reply to message #780532] Wed, 18 January 2012 20:09 Go to previous message
Sai Missing name is currently offline Sai Missing nameFriend
Messages: 25
Registered: March 2011
Junior Member
Thank you very much! Really appreciate your help.

-Sai

Satyam Kandula wrote on Wed, 18 January 2012 08:40
If your non-UI based listener needs to call UI object, this call should happen using asyncExec or syncExec.
For the bigger part of your question, you may get a better answer in the 'Eclipse Platform' forums.

Previous Topic:Eclipse RCP Product headless build with PDE
Next Topic:Simple question on using "Job" inside Eclipse
Goto Forum:
  


Current Time: Fri Dec 26 07:20:07 GMT 2014

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

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