|Re: Simple question on using &quot;Job&quot; inside Eclipse [message #780684 is a reply to message #780456]
||Thu, 19 January 2012 03:24
| Sai Missing name
Registered: March 2011
Thanks for your answer! Really appreciate your help.
A closely-related question, I also see JDT (and other eclipse components) uses
the class "Action" extensively. Usually, programmers override the
"public void run() "
method to do something. However, I found I still got invalid thread access errors
sometimes when accessing GUI object inside "run()", while sometimes not.
So, I am really wondering are all Action#run must be executed in UI-thread or non-UI thread? or it really depends? If so, could anyone kindly points me to some resources about code in Action is executed?
Thanks a lot
Deepak Azad wrote on Tue, 17 January 2012 23:12
> As far as I understand, the purpose of "Job" is to make the UI
> responsive and active. Thus, all Jobs should be run in a separate and
> background thread instead of the current thread. Is that right?
Of course a Job will run in a separate thread. It can be instructive to
have a look at org.eclipse.core.runtime.jobs.IJobManager and its
> //if I want to access UI object here,
> //I must wrap it using asyncExec / syncExec to avoid invalid thread access
Yes, or you can simply use UIJob if you want to do this.
Powered by FUDForum
. Page generated in 0.03557 seconds