You may have guessed I hadn't used Jobs much before.
Then I was surprised that I couldn't find much about Jobs in either
Pharo By Example, Deep Into Pharo or Enterprise Pharo.
>From digging around I made a minimal example I report
to help others' searches, and open it for improvement.
x := 1.
[x < 100] whileTrue:
[ x := x + 10.
0.1 seconds wait.
] forkAt: 30 named: 'worker'.
[ :job |
[ x < 100 ] whileTrue:
[ job current: x.
0.1 seconds wait.
title: 'Work progress...';
On 12 April 2018 at 23:02, Ben Coman <b...@openinworld.com> wrote:
> On 12 April 2018 at 18:15, Sven Van Caekenberghe <s...@stfx.eu> wrote:
>> You disappoint me, as I would expect you to trace senders/users of
>> #signalProgress: ;-)
> Yeah I knew I was being slack. I couldn't really follow its operation and
> was a bit tired.
> Actually maybe part of my confusion is that #signalProgress feels more
> like a command than a status.
> I've a slight feeling it would be better as #signallingProgress.
>> ZnClient only signals certain Notifications which a UI around it should
>> deal with.
>> For example,
>> [ :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.
> Thanks, that worked, but its a bit convoluted for my goldfish memory to
> remember each time.
> I'd expect having that as a convenience method would be useful to many.
> showProgress: 'Downloading sources...'
> during: [ :znClient |
> znClient url: 'http://files.pharo.org/sources/PharoV30.sources'.
> znClient downloadTo: FileLocator imageDirectory ].
> ZnClient class >> showProgress: title during: clientBlock
> client := ZnClient new.
> client signallingProgress: true.
> [ :bar |
> bar title: title.
> [clientBlock value: client]
> on: HTTPProgress
> do: [ :progress |
> progress isEmpty ifFalse: [ bar current: progress percentage ].
> progress resume ] ] asJob run.
> Easily discoverable as the only class-side method of ZnClient,
> and this would also make a useful howto reference.
>> But there are other UI approaches as well.
> Thanks for you prompt response.
> cheers -ben
>> > On 12 Apr 2018, at 11:25, Ben Coman <b...@openinworld.com> wrote:
>> > I see ZnClient >> downloadTo:
>> > calls ZnClient >> downloadEntityTo:
>> > which uses #withProgressDo:
>> > which indicates a progress bar might appear.
>> > But...
>> > ZnClient new
>> > url: ' https://download.libsodium.org
>> /libsodium/releases/libsodium-1.0.16-msvc.zip' ;
>> > downloadTo: FileLocator imageDirectory.
>> > doesn't show a progress bar. What is the recommended way to display
>> > cheers -ben