SubMonitor : mixing undefined ticks with known ticks [message #538043] |
Fri, 04 June 2010 16:13 |
Christophe Fondacci 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 |
Carusyte Missing name 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
|
|
|
|
Powered by
FUDForum. Page generated in 0.04397 seconds