When the UI thread is really busy, updating the UI can be problematic.
An extra fork seems to help:
(FileLocator temp / 'PharoV30.sources') ensureDelete.
[ [ :bar |
bar title: 'Downloading Sources...'.
[
ZnClient new
url:
'http://files.pharo.org/sources/PharoV30.sources';
signalProgress: true;
downloadTo: FileLocator temp ]
on: HTTPProgress
do: [ :progress |
progress isEmpty ifFalse: [ bar current:
progress percentage ].
progress resume ] ] asJob run ] fork.
> On 13 May 2016, at 01:00, Offray Vladimir Luna Cárdenas
> <[email protected]> wrote:
>
> Hi Sven,
>
> Thanks for your quick answer. I tried both approaches but I'm missing
> something. See my last attempt at http://ws.stfx.eu/KBVBAP72IWOO with the
> last one. I get a progress bar message, but not the advancements on it. What
> I'm missing?
>
> Cheers,
>
> Offray
>
> ps: The file I'm trying to download is covered by the Open Data Base License.
>
> On 12/05/16 17:24, Sven Van Caekenberghe wrote:
>> Hi Offray,
>>
>> The actual implementation of #saveContentsToFile: can be found in
>> ZnHttpSaveContentsToFile>>#performOperation where you can see how ZnClient
>> is invoked. Just copy that with signalProgress: true added and you should be
>> good.
>>
>> Alternatively, you could wrap the first expression as follows:
>>
>> ZnSignalProgress
>> value: true
>> during: [ myUrl asUrl saveContentsToFile: file ]
>>
>> ZnSignalProgress is a DynamicVariable that is used by ZnClient to figure out
>> if progress should be signalled. It takes precedence over the option
>> #signalProgress. See #withProgressDo: if you are interested.
>>
>> HTH,
>>
>> Sven
>>
>>> On 13 May 2016, at 00:14, Offray Vladimir Luna Cárdenas
>>> <[email protected]> wrote:
>>>
>>> Hi,
>>>
>>> I'm using
>>>
>>> myUrl asUrl saveContentsToFile: file
>>>
>>> to download large files and is working fine. But I would like to add a
>>> progress bar to show the progress to the user. Previously I used
>>>
>>> ===============
>>> [: bar |
>>> bar title: aString.
>>> [
>>> "A classical ZnClient download with signalProgress: true;"
>>> ]
>>> on: HTTPProgress
>>> do: [ :progress |
>>> progress isEmpty ifFalse: [ bar current: progress percentage
>>> ].
>>> progress resume ].
>>> ] asJob run.
>>> ===============
>>>
>>> but I don't know how to signal progress with "saveContentsToFile".
>>>
>>> Any hints?
>>>
>>> Thanks,
>>>
>>> Offray
>>>
>>
>>
>
>