I have a do: in Pharo that takes a long time to process. I'd like to show the progress of it to the user. How is that done in Pharo?
Asked
Active
Viewed 142 times
2
Fuhrmanator
- 11,459
- 6
- 62
- 111
-
Dear down voter who left no comment: how is this question worse than https://stackoverflow.com/questions/3951903 or https://stackoverflow.com/q/238073/1168342 or https://stackoverflow.com/q/3160699/1168342 – Fuhrmanator Nov 19 '18 at 15:31
1 Answers
8
Here are two ways:
Collectionborrows fromUIManagerand supports adisplayingProgress:every: millisecondsvariant ofdo::(1 to: 60) do: [ :e | (Delay forSeconds: 0.5) wait "simulate a delay" ] displayingProgress: [ :e | 'waiting ' , e asString ] every: 1000You can play with the
every:on this example to see that if you set it to less than 1000ms, it will update more often (setting it to 100 will show you every value of the interval).Also, you can simply use
displayingProgress: 'Waiting...'to only show the same string the whole time, without a block.Using the
Jobclass. Here's a similar solution as above:myColl := 1 to: 20. [ :job | myColl do: [ :e | job progress: e / myColl size; title: 'waiting ' , e asString. (Delay forSeconds: 0.5) wait ] ] asJob run
Fuhrmanator
- 11,459
- 6
- 62
- 111