|Confused on the subclasses of EventListener in eclipse [message #780463]
||Wed, 18 January 2012 06:43
| Sai Missing name
Registered: March 2011
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.
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?
Powered by FUDForum
. Page generated in 0.01851 seconds