Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Long running wizard process
Long running wizard process [message #467460] Tue, 31 January 2006 17:42 Go to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 14
Registered: July 2009
Junior Member
I have a wizard that takes about 20-30 seconds to complete. The Eclipse
wizard dialog makes the call to my wizard's performFinish method on the UI
thread. This makes the Eclipse UI largely unresponsive (aka frozen) while
the code is executing. The only time the UI appears to get any cycles is
when the progress bar is updated, but that's not enough the keep the UI
responsive.

Does anyone have any ideas how to free up the UI thread while my process is
running, while still not dismissing the wizard dialog until the process is
complete?

- Konstantin
Re: Long running wizard process [message #467464 is a reply to message #467460] Tue, 31 January 2006 17:57 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Put most of your wizard performFinish() in a Job (another thread). If
you do need to update a UI component, make short calls back out of your
Job (either display.syncExec(*) or display.asyncExec(*))

Later,
PW


Re: Long running wizard process [message #467467 is a reply to message #467464] Tue, 31 January 2006 18:06 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 14
Registered: July 2009
Junior Member
I don't think this is going to work. If I spin off a separate job, the
peformFinish() method will complete and the wizard will close. I want to
keep the wizard open and keep updating it's progress bar while I am doing
the work. I can create a polling loop in the performFinish method, but I
don't know what method I should call inside the loop to let the UI do it's
thing.

- Konstantin

"Paul Webster" <pwebster@ca.ibm.com> wrote in message
news:dro8fk$eqt$2@utils.eclipse.org...
> Put most of your wizard performFinish() in a Job (another thread). If you
> do need to update a UI component, make short calls back out of your Job
> (either display.syncExec(*) or display.asyncExec(*))
>
> Later,
> PW
Re: Long running wizard process [message #467471 is a reply to message #467467] Tue, 31 January 2006 18:43 Go to previous messageGo to next message
Alex Blewitt is currently offline Alex BlewittFriend
Messages: 946
Registered: July 2009
Senior Member
So there's two options:

1) Keep the wizard open whilst the long running job happens, and possibly block the UI whilst doing so
2) Close the wizard and run the job in the background

Is there any problem with closing the wizard early? You can still have your background job fire up a dialog box in the case of failure, or update the resource(s) once the job is succesful. It's probably because the question is so abstract that it's difficult to know what you're trying to achieve and in what context.

At the end of the day though, those are your two choices; and you have to figure out which one of them is right for you.

Alex.
Re: Long running wizard process [message #467474 is a reply to message #467471] Tue, 31 January 2006 19:48 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 14
Registered: July 2009
Junior Member
The wizard is a project creation wizard. Dismissing the wizard before the
project is completely created is inconsistent with how other project
creation wizards function, so it's a non-starter. I am hoping that someone
knows a way to keep the wizard up while doing the work on the background
thread...

- Konstantin


"Alex Blewitt" <alex_blewitt@yahoo.com> wrote in message
news:1415916.1138733019568.JavaMail.root@cp1.javalobby.org...
> So there's two options:
>
> 1) Keep the wizard open whilst the long running job happens, and possibly
> block the UI whilst doing so
> 2) Close the wizard and run the job in the background
>
> Is there any problem with closing the wizard early? You can still have
> your background job fire up a dialog box in the case of failure, or update
> the resource(s) once the job is succesful. It's probably because the
> question is so abstract that it's difficult to know what you're trying to
> achieve and in what context.
>
> At the end of the day though, those are your two choices; and you have to
> figure out which one of them is right for you.
>
> Alex.
Re: Long running wizard process [message #467480 is a reply to message #467460] Tue, 31 January 2006 20:29 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: pawcio.nonexistent.pl

Konstantin Komissarchik napisał(a):
> Does anyone have any ideas how to free up the UI thread while my process is
> running, while still not dismissing the wizard dialog until the process is
> complete?

Use WizardDialog built-in functionality. There is the thread about it on
eclipse.platform group:

Subject: ProgressMonitor in a Wizard
Date: Sun, 22 Jan 2006 14:29:21 +0100
Message-ID: <dr01b8$n24$1@utils.eclipse.org>

- pw
Re: Long running wizard process [message #467482 is a reply to message #467480] Tue, 31 January 2006 20:37 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 14
Registered: July 2009
Junior Member
Could you forward me that thread? I don't have local history going that far
back and eclipse.org archives only go back as far as 01/23.

Thanks,

- Konstantin

"Pawe
Re: Long running wizard process [message #467484 is a reply to message #467474] Tue, 31 January 2006 20:58 Go to previous messageGo to next message
Alex Blewitt is currently offline Alex BlewittFriend
Messages: 946
Registered: July 2009
Senior Member
You could always subclass your own WizardDialog instead of using the standard one.

Or, you could have the Next button take you to a final 'confirmation' page, and when you click 'next' do the computation in a background thread. When teh thread has finished, you can then enable the Finish button in the wizard.

Alex.
Re: Long running wizard process [message #467502 is a reply to message #467482] Wed, 01 February 2006 08:04 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: pwalczak.opi.org.pl

Konstantin Komissarchik napisał(a):
> Could you forward me that thread? I don't have local history going that far
> back and eclipse.org archives only go back as far as 01/23.

My post from that thread (give attention to the fist argument of the
run() method - it tells if the runnable should be run in a separate
thread):


> Nick napisał(a):
>
>> hi everybody,
>>
>> can anybody give me a hint how to use the progress monitor
>> in a wizard? are there any tutorials?
>
>
> public class WizardTest extends Wizard {
>
> public WizardTest() {
> this.setNeedsProgressMonitor(true);
> }
>
> public boolean performFinish() {
>
> try {
> getContainer().run(true, false,
> new IRunnableWithProgress() {
>
> public void run(IProgressMonitor monitor)
> throws InvocationTargetException,
> InterruptedException {
>
> monitor.beginTask("Enything. ", 100);
> for (int i = 0; i < 100; ++i) {
> Thread.sleep(100);
> monitor.subTask("Performing task "
> + (i + 1) + ". ");
> monitor.worked(1);
> }
> monitor.done();
>
> }
> });
> } catch (InvocationTargetException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> } catch (InterruptedException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> }
>
> return true;
> }
> }
Re: Long running wizard process [message #467506 is a reply to message #467502] Wed, 01 February 2006 08:30 Go to previous messageGo to next message
Alex Blewitt is currently offline Alex BlewittFriend
Messages: 946
Registered: July 2009
Senior Member
That wouldn't solve the problem; the wizard would still disappear after the thread is launched and the performFinish() method returns, wouldn't it?

Alex.
Re: Long running wizard process [message #467509 is a reply to message #467506] Wed, 01 February 2006 09:09 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: pwalczak.opi.org.pl

Alex Blewitt napisał(a):
> That wouldn't solve the problem; the wizard would still disappear after the thread is launched and the performFinish() method returns, wouldn't it?

Did I miss something? The point is to perform lengthy operatation after
wizard Finish button has been clicked, right? What I showed is - I
believe - typical way to do that. The wizard dialog will not disappear
until a job is finished. Otherwise the presense of the progress bar in
the wizard dialog would not have any sense.

- pw
Re: Long running wizard process [message #467511 is a reply to message #467509] Wed, 01 February 2006 11:17 Go to previous message
Alex Blewitt is currently offline Alex BlewittFriend
Messages: 946
Registered: July 2009
Senior Member
My mistake. I thought the performFinish() wouldn't block if the thread is forked; however, you're right, and the performFinish() is blocked until the runnable completes.

Thanks for helping me to learn something new today :-)

Alex.
Previous Topic:JFace Data Binding - nested properties
Next Topic:Dialog Resizing
Goto Forum:
  


Current Time: Tue May 21 18:30:36 GMT 2019

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

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

Back to the top