Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » SubMonitor : mixing undefined ticks with known ticks
SubMonitor : mixing undefined ticks with known ticks [message #538043] Fri, 04 June 2010 16:13 Go to next message
Christophe Fondacci is currently offline Christophe FondacciFriend
Messages: 95
Registered: July 2009
Location: Paris
Member
Hello all,

I am new to SubMonitor usage and have studied the jdocs. The SubMonitor seems not to work as what I would have expected / understood from the docs.

Here it is :
* Got a main process, taking a IProgressMonitor, converting it to SubMonitor
* It then run a method which generates an undefined amount of ticks (many)
* Then it has 5 known steps to do and it is finished.

Here is roughly how I implemented this :
SubMonitor monitor = SubMonitor.convert(mainMonitor,"Start",10000);
// Here I would like this process to take up to 96% of the bar
doProcess1(monitor.newChild(9600));
// Now that this is done, I need 5 more tasks
monitor.setWorkRemaining(5);
task1();
monitor.worked(1);
task2();
// etc 


I would have expected :
* Process1 is run and consume ticks (generally way less than 9600)
* The call to setWorkRemaining would redispatch the empty space of the progress for exactly 5 more ticks
* Each execution of tasks would take 1/5 of the empty space (this is what says the javadoc, isn't it ?)

What I got is that the monitor.setWorkRemaining(5) does not update the progress (looks ok for me), but the first call to monitor.worked(1) seems to place the filled progress up to 95% (that is to say the extreme end).

The Javadoc of setWorkRemaining() literally says :
When this method is called, the remaining space on the progress monitor is redistributed into the given number of ticks.


Does it work as expected ? Because, when I read "redistributed", I expect them to be equally important...


Am I doing something wrong / bad ?
Thanks,
Christophe
http://www.nextep-softwares.com
Re: SubMonitor : mixing undefined ticks with known ticks [message #538138 is a reply to message #538043] Sat, 05 June 2010 15:26 Go to previous messageGo to next message
Carusyte Missing name is currently offline Carusyte Missing nameFriend
Messages: 27
Registered: July 2009
Junior Member
Hi, Chris, I am not sure about the doc, but in order to realize your expectation (roughly), according to my own experience, try to code this way:
SubMonitor monitor = SubMonitor.convert(mainMonitor,"Start",10000);
// Here I would like this process to take up to 96% of the bar
doProcess1(monitor.newChild(9600)); // in the doProcess1, you have to call sm.worked(x) as your job progresses, you can even redistribute the workload using sm.setWorkRemaining(xxx);
// Once you split your work with "child", I think it's better to do it consistently.
// monitor.setWorkRemaining(5);
SubMonitor smTask1 = monitor.newChild(300);
task1();  // I think it's better to pass smTask1 into this method since you can already quantify workload, but it's ok as long as you "newChild" consistently along the job, just that the progress bar won't update.
SubMonitor smTask2 = monitor.newChild(100);
task2();
// have to finish the work
monitor.done();  // the progressbar would probably jump from 96% straight to 100%
// etc 


Hope this helps in a way.

[Updated on: Sat, 05 June 2010 15:31]

Report message to a moderator

Re: SubMonitor : mixing undefined ticks with known ticks [message #538195 is a reply to message #538138] Sun, 06 June 2010 09:48 Go to previous message
Christophe Fondacci is currently offline Christophe FondacciFriend
Messages: 95
Registered: July 2009
Location: Paris
Member
mmm, not sure about your proposal. I don't think calling newChild when you don't need to report any progress on the child progress is a good practice. newChild() is to be passed to methods accepting progress monitor which can themselves report progress.

This is not what I need to do: I need to execute methods which do not report progress and advance progress after each call.

There are many ways I could "get" this working (actually it works already, but the progress display is not what I would have expected), I only need the best practice here...

Thanks anyway,
Christophe
http://www.nextep-softwares.com
Previous Topic:"Extract" the property view
Next Topic:size of WorkbenchWindowControlContribution
Goto Forum:
  


Current Time: Thu Dec 18 04:12:31 GMT 2014

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

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