I didn't mention that my question comes from trying and finding bugs
in the method BlockClosure>>silentlyValue, in Pharo 2.0 (should be in
1.4 also):

silentlyValue
        "evaluates the receiver but avoiding progress bar notifications to show 
up."
        
        ^[ self value ]
                on: ProgressInitiationException
                do: [ :ex |
                        ex sendNotificationsTo: [ :min :max :curr |
                                self traceCr: min printString,'  ',max 
printString,'  ',curr printString; cr
                        ].
                ].

----> "; cr" has to be removed from code. After this easy fix, the
other bug makes visible: #silentlyValue is not that silently with
nested progress bars.  Try:

[
'main task'
        displayProgressFrom: 0 to: 5
        during: [ :bar |
                0 to: 5 do: [:x | bar value: x.
                (Delay forMilliseconds: 200) wait.
                
                'nested task ' , x printString
                        displayProgressFrom: 5 to: 10
                        during: [ :bar2 |
                                5 to: 10 do: [:x2 | bar2 value: x2.
                                (Delay forMilliseconds: 200) wait] ] ] ].

] silentlyValue.


Cheers.
Martín


On Tue, May 8, 2012 at 12:28 AM, Martin Dias <tinchod...@gmail.com> wrote:
> Hi all.
>
> Given the next code, could you explain me why nested progress bars are
> not handled by my #on:do:?
> How can I achieve that?
>
> [
> 'main task'
>        displayProgressFrom: 0 to: 5
>        during: [ :bar |
>                0 to: 5 do: [:x | bar value: x.
>                (Delay forMilliseconds: 200) wait.
>
>                'nested task ' , x printString
>                        displayProgressFrom: 5 to: 10
>                        during: [ :bar2 |
>                                5 to: 10 do: [:x2 | bar2 value: x2.
>                                (Delay forMilliseconds: 200) wait] ] ] ]
>
> ]       on: ProgressInitiationException
>        do: [ :ex |
>                ex sendNotificationsTo: [ :min :max :curr |
>                        self traceCr: curr ] ].
>
>
> Thanks in advance.
> Martín

Reply via email to