You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: General/ProgressBar.md
+6-8
Original file line number
Diff line number
Diff line change
@@ -1,23 +1,21 @@
1
1
# Progress bar
2
2
3
-
This document will cover different ways in Pharo to display a progress bar when executing code.
3
+
This document covers different ways to display a progress bar during code execution.
4
4
5
5
## Progress bar on iterators
6
6
7
-
The easiest way to create a progress bar is to use the method `do:displayingProgress:`. This method is present on Collections and will add a progress bar updating during the iteration.
7
+
The easiest way to create a progress bar is to use the method `do:displayingProgress:`. This method is available on Collections and adds a progress bar automatically updated during iterations.
8
8
9
9
```Smalltalk
10
10
(1 to: 100) do: [ :each | each logCr. 100 milliSecond wait. ] displayingProgress: [ :each | 'Iterating step ' , each asString ]
11
11
```
12
12
13
-
You can also customize the refresh time if you want better performances:
13
+
Refresh time can also be customized if better performances are needed. For example, the following code will update the progress bar every 2 seconds:
14
14
15
15
```Smalltalk
16
16
(1 to: 100) do: [ :each | each logCr. 100 milliSecond wait. ] displayingProgress: [ :each | 'Iterating step ' , each asString ] every: 2000
17
17
```
18
18
19
-
This code will update the progress bar every 2 seconds.
20
-
21
19
## Use Jobs
22
20
23
21
An other way to display a progress bar is to use Jobs.
@@ -48,9 +46,9 @@ UIManager default
48
46
] ]
49
47
```
50
48
51
-
While using this method be careful of performances when you have a lot a really fast steps.
49
+
Be careful while using this method. It might cause performance issues when time between two steps is short.
52
50
53
-
Here is a way to manage this:
51
+
However, the following code shows a way to avoid these issues.
54
52
55
53
```Smalltalk
56
54
UIManager default
@@ -70,4 +68,4 @@ UIManager default
70
68
] ]
71
69
```
72
70
73
-
This will update the progress bar every 500 milliseconds instead of updating the bar each time we call #value: or #title:
71
+
The trick is to leave at least 500 milliseconds between two updates instead of updating the bar each time we call `value:` or `title:`.
0 commit comments