Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Populating a table asynchronously
Populating a table asynchronously [message #334844] Tue, 03 March 2009 04:39 Go to next message
Andrei Serea is currently offline Andrei SereaFriend
Messages: 16
Registered: July 2009
Junior Member
Hi all,

I have a problem. I've been up all night trying to create a simple dialog
containing a table that will fill up as a background job supplies the info.
To be more precise, the job does a svn checkout and I want to show the
progress (files downloaded so far) in a table. Problem is I don't know how
to set the input for the table's content provider without freezing the UI.
An example would help a lot... thanks!
Re: Populating a table asynchronously [message #334845 is a reply to message #334844] Tue, 03 March 2009 07:37 Go to previous messageGo to next message
Hitesh  is currently offline Hitesh Friend
Messages: 19
Registered: July 2009
Junior Member
Andrei Serea wrote:

> Hi all,

> I have a problem. I've been up all night trying to create a simple dialog
> containing a table that will fill up as a background job supplies the info.
> To be more precise, the job does a svn checkout and I want to show the
> progress (files downloaded so far) in a table. Problem is I don't know how
> to set the input for the table's content provider without freezing the UI.
> An example would help a lot... thanks!

http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jface.s nippets/Eclipse%20JFace%20Snippets/org/eclipse/jface/snippet s/viewers/Snippet045TableViewerFillFromBackgroundThread.java ?view=markup

http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jface.s nippets/Eclipse%20JFace%20Snippets/org/eclipse/jface/snippet s/viewers/Snippet046UpdateViewerFromBackgroundThread.java?vi ew=markup

The above links should be helpful.
And http://wiki.eclipse.org/index.php/JFaceSnippets

Hitesh
Re: Populating a table asynchronously [message #334846 is a reply to message #334845] Tue, 03 March 2009 10:18 Go to previous messageGo to next message
Andrei Serea is currently offline Andrei SereaFriend
Messages: 16
Registered: July 2009
Junior Member
Thanks Hitesh. It is very close to what I needed, but not exactly.
In those examples the input for the viewer comes directly from the same
thread as the one that updates the viewer.
In my case the input is supplied asynchronously by a non-ui thread, so I
cannot update the viewer from that thread (i get a invalid thread access
exception). The only way I imagine is to listen for changes in the ui
thread. But listening, although done with semaphores in a async run from
the ui thread, it still freazez the ui.
I'm out of ideas...almost. I'm gonna try the Realm and IObservable api
right now.
But I appreciate any guiding.

Thanks a lot!
Re: Populating a table asynchronously [message #334847 is a reply to message #334846] Tue, 03 March 2009 10:43 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
This is not correct! The example uses a TimerTask which is a none-ui
thread and to sync back it uses the Display#asyncExec!

Tom

Andrei Serea schrieb:
> Thanks Hitesh. It is very close to what I needed, but not exactly.
> In those examples the input for the viewer comes directly from the same
> thread as the one that updates the viewer.
> In my case the input is supplied asynchronously by a non-ui thread, so I
> cannot update the viewer from that thread (i get a invalid thread access
> exception). The only way I imagine is to listen for changes in the ui
> thread. But listening, although done with semaphores in a async run from
> the ui thread, it still freazez the ui.
> I'm out of ideas...almost. I'm gonna try the Realm and IObservable api
> right now.
> But I appreciate any guiding.
>
> Thanks a lot!
>
Re: Populating a table asynchronously [message #334851 is a reply to message #334847] Tue, 03 March 2009 13:22 Go to previous messageGo to next message
Andrei Serea is currently offline Andrei SereaFriend
Messages: 16
Registered: July 2009
Junior Member
You are right. The only thing I might add is that in the example, syncExec
is called instead of asyncExec.
I had no idea one could access the shell and display from a non-ui thread.
it still doesn't make sense.
But now, after digging for a couple of hours into realms, I am quite
curious. Can anyone point me towards a place where I could read more about
realms (except the existing snippets and docs from the eclipse site)?

Anywho, thanks a million!!!
Re: Populating a table asynchronously [message #334855 is a reply to message #334851] Tue, 03 March 2009 16:40 Go to previous message
Eclipse UserFriend
Originally posted by: wegener.cboenospam.com

"Andrei Serea" <andrei.serea@gmail.com> wrote in message
news:32e185bd5fe6d832add0cd42d8e65ed0$1@www.eclipse.org...
> You are right. The only thing I might add is that in the example, syncExec
> is called instead of asyncExec.
> I had no idea one could access the shell and display from a non-ui thread.
> it still doesn't make sense.

You can't access the shell and display from a non-ui thread. The syncExec
method still calls the run method on the Display's UI thread. The
difference between async and sync is the point that the call returns to the
non-ui thread. For asyncExec, the call returns after the runnable is
scheduled on the UI thread. With syncExec, the method schedules the
runnable on the UI thread and then waits for the runnable to complete. This
blocks the non-UI thread until the runnable completes. Both calls involve
two separate threads (assuming that the sync/asyncExec call isn't made from
the UI thread.)


> But now, after digging for a couple of hours into realms, I am quite
> curious. Can anyone point me towards a place where I could read more about
> realms (except the existing snippets and docs from the eclipse site)?
>
> Anywho, thanks a million!!!
>
Previous Topic:Ganymede SR2 update updates eclipse.ini !
Next Topic:Switch perspective open Welcome page
Goto Forum:
  


Current Time: Thu Apr 25 10:21:51 GMT 2024

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

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

Back to the top