Confused on the subclasses of EventListener in eclipse [message #780463] |
Wed, 18 January 2012 01:43  |
Eclipse User |
|
|
|
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 #780629 is a reply to message #780532] |
Wed, 18 January 2012 15:09  |
Eclipse User |
|
|
|
Thank you very much! Really appreciate your help.
-Sai
Satyam Kandula wrote on Wed, 18 January 2012 08:40If 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.
|
|
|
Powered by
FUDForum. Page generated in 0.04544 seconds