Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Jobs are freezing my whole app
Jobs are freezing my whole app [message #513086] Mon, 08 February 2010 09:18 Go to next message
Tobias Hoppenthaler is currently offline Tobias Hoppenthaler
Messages: 21
Registered: July 2009
Junior Member
Hi there,
I am trying to invoke a bunch of jobs in order to generate files. Each
job generates a bunch of files from a source file. My Problem is, that I
do not get any progress information at all, i.e. I do not get the
progress bar dialog, that I get when I invoke a single job. Additionally
my application is rendered unusable. I can see the workers being invoked
in the debug view and after a while, when all work is done, I can use
the app again, but actually I wanted to use jobs in order to make the
app usable all the way during the work is being done. Any ideas, what I
am donig wrong? See source below.

Thanks,

Tobias

##############SOURCE###############

ArrayList<Job> jobList = new ArrayList<Job>();

IProgressMonitor pm = Job.getJobManager().createProgressGroup();
pm.beginTask("FLW",fileListFLW.size());

for (String file : fileListFLW) {

Job job = new GenerateJob(file);
job.setUser(true);
jobList.add(job);
job.setProgressGroup(pm, fileListFLW.size());
job.schedule();
}
for (Job job : jobList) {
if (pm.isCanceled()) {
return;a
}
try {
job.join();
pm.worked(1);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
pm.done();
}
}
private class GenerateFlowJob extends Job {

protected String file, outputDir, language;

public GenerateFlowJob(String file,
String outputDir, String language) {
super(file);
this.file = file;
this.outputDir = outputDir;
this.language = language;
}

@Override
protected IStatus run(IProgressMonitor monitor) {
monitor.beginTask(this.file, IProgressMonitor.UNKNOWN);
FlowGeneratorHandler.generateFlow(file,
outputDir, language);
monitor.done();
return Status.OK_STATUS;
}

}
Re: Jobs are freezing my whole app [message #513153 is a reply to message #513086] Mon, 08 February 2010 18:50 Go to previous messageGo to next message
Prakash G.R. is currently offline Prakash G.R.
Messages: 621
Registered: July 2009
Senior Member
On 09/02/10 12:33 AM, Tobias Hoppenthaler wrote:
> Hi there,
> I am trying to invoke a bunch of jobs in order to generate files. Each
> job generates a bunch of files from a source file. My Problem is, that I
> do not get any progress information at all, i.e. I do not get the
> progress bar dialog, that I get when I invoke a single job. Additionally
> my application is rendered unusable. I can see the workers being invoked
> in the debug view and after a while, when all work is done, I can use
> the app again, but actually I wanted to use jobs in order to make the
> app usable all the way during the work is being done. Any ideas, what I
> am donig wrong? See source below.

Why don't you generate all the files in a single job?

- Prakash
Platform UI Team, IBM

Blog <http://blog.eclipse-tips.com>
Twitter <http://www.twitter.com/Eclipse_Tips>
Re: Jobs are freezing my whole app [message #513239 is a reply to message #513086] Tue, 09 February 2010 08:27 Go to previous messageGo to next message
Paul Webster is currently offline Paul Webster
Messages: 6850
Registered: July 2009
Location: Ottawa
Senior Member

Tobias Hoppenthaler wrote:
>
> ##############SOURCE###############
>
> ArrayList<Job> jobList = new ArrayList<Job>();
>
> IProgressMonitor pm = Job.getJobManager().createProgressGroup();
> pm.beginTask("FLW",fileListFLW.size());

You've assigned your group monitor a number here.

>
> for (String file : fileListFLW) {
>
> Job job = new GenerateJob(file);
> job.setUser(true);
> jobList.add(job);
> job.setProgressGroup(pm, fileListFLW.size());

This is not like the javadoc example on createProgressGroup() at all.
It looks like you need setProgressGroup(pm, 1); Check out the javadoc
example in createProgressGroup().


> pm.worked(1);

You also don't call your worked(*) in this code, your Job should deal
with its progress monitor itself (as it will be handed a sub progress
monitor). Just assume your job *cannot* know it is running as part of a
progress group, and have it do work in its run(*) method as if it were
reporting progress normally.

Later,
PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Re: Jobs are freezing my whole app [message #513344 is a reply to message #513153] Tue, 09 February 2010 14:27 Go to previous messageGo to next message
Tobias Hoppenthaler is currently offline Tobias Hoppenthaler
Messages: 21
Registered: July 2009
Junior Member
Because then they are not being processed in parallel and it takes more
time.
On 09.02.2010 05:44, Prakash G.R. wrote:

> Why don't you generate all the files in a single job?
>
> - Prakash
> Platform UI Team, IBM
>
> Blog <http://blog.eclipse-tips.com>
> Twitter <http://www.twitter.com/Eclipse_Tips>
Re: Jobs are freezing my whole app [message #513345 is a reply to message #513086] Tue, 09 February 2010 14:30 Go to previous message
Tobias Hoppenthaler is currently offline Tobias Hoppenthaler
Messages: 21
Registered: July 2009
Junior Member
It seems that my problem consisted of two components:

a) job.join() was called for each job in the command handler and that
seemed to render my app unusable.
b) the progress view was in my app

When I removed the join clause from my code, suddenly it worked, but I
had no progress info. Then I added the progress view and everything was
fine.
Cheers,

Tobias
On 08.02.2010 20:03, Tobias Hoppenthaler wrote:
> Hi there,
> I am trying to invoke a bunch of jobs in order to generate files. Each
> job generates a bunch of files from a source file. My Problem is, that I
> do not get any progress information at all, i.e. I do not get the
> progress bar dialog, that I get when I invoke a single job. Additionally
> my application is rendered unusable. I can see the workers being invoked
> in the debug view and after a while, when all work is done, I can use
> the app again, but actually I wanted to use jobs in order to make the
> app usable all the way during the work is being done. Any ideas, what I
> am donig wrong? See source below.
>
> Thanks,
>
> Tobias
>
Previous Topic:Eclipse actionSet actions enable/disable
Next Topic:Invoking the Workspace Launcher Dialog
Goto Forum:
  


Current Time: Sun Apr 20 19:50:32 EDT 2014

Powered by FUDForum. Page generated in 0.02499 seconds