Skip navigation.
 
mlRe: Updating progress bar from multiple nested functions - best way?
FROM : j o a r
DATE : Mon Apr 18 15:15:12 2005

On 2005-04-18, at 14.45, Johnny Deadman wrote:

> I want to put up a progress indicator BUT the process is split up
> between many independent objects which don't know about each other and
> don't know whether the job they're doing (eg formatting a paragraph,
> analysing a scene) is a one-shot or part of a bigger picture.


If you want to have a determinate progress indicator you need to know
the scope of the operation in advance. It doesn't sound like you have
this information in your current implementation. You would probably
need to add some sort of pre-flight step, where you compute how many
separate steps are involved in the operation, and perhaps also their
relative "weight".

> It seems wrong to have to pass each object a reference to the progress
> bar, the proportion of the task completed, and the proportion of the
> task they are responsible for. It seems equally wrong to insist that
> each object retain a reference to the top-level object and notify it.
> I feel they should be agnostic about the context from which they are
> invoked.


I would probably investigate using some sort of "progress delegate".
This would in practice be the same thing as a reference to the parent,
but might on a conceptual level be cleaner. By using the delegate, a
child could communicate it's current status, and have this status
propagated upwards for display to the user.
If you operate in a context where there is no need to indicate
progress, you could just skip the pre-flight step and not set a
progress delegate.

j o a r

Related mailsAuthorDate
mlUpdating progress bar from multiple nested functions - best way? Johnny Deadman Apr 18, 14:45
mlRe: Updating progress bar from multiple nested functions - best way? j o a r Apr 18, 15:15
mlRe: Updating progress bar from multiple nested functions - best way? John Brownlow Apr 19, 22:35
mlRe: updating progress bar from multiple nested functions - best way? Adam Swift Apr 19, 22:47