Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Cannot able to update TableItem dynamically from a thread written inside asyncexec Method
Cannot able to update TableItem dynamically from a thread written inside asyncexec Method [message #289813] Thu, 11 August 2005 00:59 Go to next message
Eclipse UserFriend
Originally posted by: muthu.velappan.aspiresys.com

Hi All,

I'm into the development of a plug-in which monitors others system and
updates its resources in the Table View.

I'm using a thread written inside aysncexec method which monitors the system
continuously and gets the result from ResultAdapter class. Upto this
everything works fine.

The problem occurs, when I try to update the result from ResultAdapter into
Tableview. The result gets updated into the TableView, but I can able to
view it only when I stop that thread. It doesn't shows the result in table
while the thread is running but If I create a new column inside
getElements() method of ContentProvider I can able to see the output even
when the thread is running. Also, If I switch to other windows the plug-in
hangs indefinitely because of the thread written inside the asyncexec
method.

Can any one please help me on this stating how to proceed or where I'm going
wrong.

Thanks in Advance

Muthu.
Re: Cannot able to update TableItem dynamically from a thread written inside asyncexec Method [message #289848 is a reply to message #289813] Thu, 11 August 2005 10:13 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

This is a common misconception about asyncexec. :-(

Asyncexec does not create a thread to run the Runnable. What it does it
does is to queue the runnable to run on the UI display thread the next
time the UI thread is free. So instead of your runnable running on a
background thread, it is actually running on the UI thread. So you are
blocking all UI updates while running your monitors.

You need to reverse this 180 degrees. Create a Job (lookup Jobs in:
http://eclipse.org/articles/Article-Concurrency/jobs-api.htm l )
This job will then run in the background and monitor what you want to
monitor. Then when you want to update the UI, your job should do an
asyncExec and the runnable passed to it should do only the update to the
UI and nothing else. The async runnable should end as soon as possible
so as not to tie up the UI thread.



--
Thanks,
Rich Kulp
Re: Cannot able to update TableItem dynamically from a thread written inside asyncexec Method [message #289884 is a reply to message #289848] Fri, 12 August 2005 02:47 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: muthu.velappan.aspiresys.com

Thanks Rich,

I have understood that asyncexec concept . I have used the Timer and
TimerTask classes of java.util package to execute the monitoring thread run
in a background and the asyncexec method will just update the UI instead of
holding the thread continuously.Now everything seems to work fine.

Is there any difference in implementing the background thread using the JOB
class instead of Timer and TimerTask classes.

Regards
Muthu.


"Rich Kulp" <richkulp@us.NO_SPAM.ibm.com> wrote in message
news:ddfme4$i54$1@news.eclipse.org...
> This is a common misconception about asyncexec. :-(
>
> Asyncexec does not create a thread to run the Runnable. What it does it
> does is to queue the runnable to run on the UI display thread the next
> time the UI thread is free. So instead of your runnable running on a
> background thread, it is actually running on the UI thread. So you are
> blocking all UI updates while running your monitors.
>
> You need to reverse this 180 degrees. Create a Job (lookup Jobs in:
> http://eclipse.org/articles/Article-Concurrency/jobs-api.htm l )
> This job will then run in the background and monitor what you want to
> monitor. Then when you want to update the UI, your job should do an
> asyncExec and the runnable passed to it should do only the update to the
> UI and nothing else. The async runnable should end as soon as possible so
> as not to tie up the UI thread.
>
>
>
> --
> Thanks,
> Rich Kulp
Re: Cannot able to update TableItem dynamically from a thread written inside asyncexec Method [message #289895 is a reply to message #289884] Fri, 12 August 2005 11:11 Go to previous message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

Jobs allow thread sharing and scheduling. You can schedule your job to
start at specific delay and it will wait, and then when it executes it
will be given a thread from the thread pool. That way you don't have
your own threads hanging around mostly waiting.

--
Thanks,
Rich Kulp
Previous Topic:Update a view title to be bold
Next Topic:3.1 problem with accelerators
Goto Forum:
  


Current Time: Thu May 29 02:24:03 EDT 2025

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

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

Back to the top