Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » update a dialog with a thread
update a dialog with a thread [message #440661] Thu, 05 August 2004 12:51 Go to next message
william is currently offline williamFriend
Messages: 15
Registered: July 2009
Junior Member
hi,

i'm trying to create a progress bar for transfering files between a client
and a server.

so, i made a dialog containing a progress bar, and a cancel button (for
stoping the transfert if i want).
next, i create a thread (which takes the dialog as parameter allowing the
thread to access to the elements of the dialog) and i start it.

i'can't see the progress bar moving but all the dialog is block and i
can't push the cancel button.

thanks for helping me


William
Re: update a dialog with a thread [message #440670 is a reply to message #440661] Thu, 05 August 2004 14:27 Go to previous messageGo to next message
Steve Northover is currently offline Steve NorthoverFriend
Messages: 1636
Registered: July 2009
Senior Member
You need to make sure that the UI-thread is processing events. The
sync/asyncExec() runnables that you are using to update the progress bar
from the background thread need to just update the bar and return. If you
run a loop in the runnable, this will block the UI-thread.

"william" <william.ferreira@laposte.net> wrote in message
news:cetag9$ild$1@eclipse.org...
> hi,
>
> i'm trying to create a progress bar for transfering files between a client
> and a server.
>
> so, i made a dialog containing a progress bar, and a cancel button (for
> stoping the transfert if i want).
> next, i create a thread (which takes the dialog as parameter allowing the
> thread to access to the elements of the dialog) and i start it.
>
> i'can't see the progress bar moving but all the dialog is block and i
> can't push the cancel button.
>
> thanks for helping me
>
>
> William
>
Re: update a dialog with a thread [message #440681 is a reply to message #440670] Fri, 06 August 2004 07:52 Go to previous messageGo to next message
william is currently offline williamFriend
Messages: 15
Registered: July 2009
Junior Member
thanks a lot, it's working...
but there is a little problem...
i created a runnable taking the dialog in parameter, and in the runnable i
did a loop in which i call syncExec() runnable for udpating my progress
bar (update and return). But the cancel button is activated only when the
syncExec() runnable runs (during all the treatment of the first runnable
the dialog is block) and i don't understand why....

i have an other question : what is the difference between sync and
asyncExec() ?

thanks


Steve Northover wrote:

> You need to make sure that the UI-thread is processing events. The
> sync/asyncExec() runnables that you are using to update the progress bar
> from the background thread need to just update the bar and return. If you
> run a loop in the runnable, this will block the UI-thread.

> "william" <william.ferreira@laposte.net> wrote in message
> news:cetag9$ild$1@eclipse.org...
> > hi,
> >
> > i'm trying to create a progress bar for transfering files between a client
> > and a server.
> >
> > so, i made a dialog containing a progress bar, and a cancel button (for
> > stoping the transfert if i want).
> > next, i create a thread (which takes the dialog as parameter allowing the
> > thread to access to the elements of the dialog) and i start it.
> >
> > i'can't see the progress bar moving but all the dialog is block and i
> > can't push the cancel button.
> >
> > thanks for helping me
> >
> >
> > William
> >
Re: update a dialog with a thread [message #440688 is a reply to message #440681] Fri, 06 August 2004 09:30 Go to previous messageGo to next message
william is currently offline williamFriend
Messages: 15
Registered: July 2009
Junior Member
it's ok, i found my problem
the next time i will test my program before writing....

but i don't ever know the answer of my second question ...(what is the
difference between sync and asyncExec() ?)

thanks a lot ....

william wrote:

> thanks a lot, it's working...
> but there is a little problem...
> i created a runnable taking the dialog in parameter, and in the runnable i
> did a loop in which i call syncExec() runnable for udpating my progress
> bar (update and return). But the cancel button is activated only when the
> syncExec() runnable runs (during all the treatment of the first runnable
> the dialog is block) and i don't understand why....

> i have an other question : what is the difference between sync and
> asyncExec() ?

> thanks


> Steve Northover wrote:

> > You need to make sure that the UI-thread is processing events. The
> > sync/asyncExec() runnables that you are using to update the progress bar
> > from the background thread need to just update the bar and return. If you
> > run a loop in the runnable, this will block the UI-thread.

> > "william" <william.ferreira@laposte.net> wrote in message
> > news:cetag9$ild$1@eclipse.org...
> > > hi,
> > >
> > > i'm trying to create a progress bar for transfering files between a
client
> > > and a server.
> > >
> > > so, i made a dialog containing a progress bar, and a cancel button (for
> > > stoping the transfert if i want).
> > > next, i create a thread (which takes the dialog as parameter allowing the
> > > thread to access to the elements of the dialog) and i start it.
> > >
> > > i'can't see the progress bar moving but all the dialog is block and i
> > > can't push the cancel button.
> > >
> > > thanks for helping me
> > >
> > >
> > > William
> > >
Re: update a dialog with a thread [message #440692 is a reply to message #440688] Fri, 06 August 2004 12:51 Go to previous messageGo to next message
Jeff Myers is currently offline Jeff MyersFriend
Messages: 396
Registered: July 2009
Senior Member
William,

With syncExec() the calling thread is suspended (blocked) until the run
on the UI thread is finished. With asyncExec() the calling thread
continues to run in parallel and independent of the run on the UI
thread. So in your code you need to wait for the UI update to occur
then continue, use syncExec. If what you're doing is independent of the
UI update (i.e. the UI update is just updating a status, etc) you should
use asyncExec.

- Jeff

william wrote:
> it's ok, i found my problem
> the next time i will test my program before writing....
>
> but i don't ever know the answer of my second question ...(what is the
> difference between sync and asyncExec() ?)
>
> thanks a lot ....
>
> william wrote:
Re: update a dialog with a thread [message #440696 is a reply to message #440692] Fri, 06 August 2004 13:14 Go to previous message
william is currently offline williamFriend
Messages: 15
Registered: July 2009
Junior Member
ok
thanks a lot...

Jeff Myers wrote:

> William,

> With syncExec() the calling thread is suspended (blocked) until the run
> on the UI thread is finished. With asyncExec() the calling thread
> continues to run in parallel and independent of the run on the UI
> thread. So in your code you need to wait for the UI update to occur
> then continue, use syncExec. If what you're doing is independent of the
> UI update (i.e. the UI update is just updating a status, etc) you should
> use asyncExec.

> - Jeff

> william wrote:
> > it's ok, i found my problem
> > the next time i will test my program before writing....
> >
> > but i don't ever know the answer of my second question ...(what is the
> > difference between sync and asyncExec() ?)
> >
> > thanks a lot ....
> >
> > william wrote:
Previous Topic:SWT on PocketPC and VGA resolution
Next Topic:How to delete ANT RUN configurations int ANT view?
Goto Forum:
  


Current Time: Thu Apr 25 03:53:47 GMT 2024

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

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

Back to the top