vbauerster / mpb

multi progress bar for Go cli applications
The Unlicense
2.31k stars 123 forks source link

Can I stop bar completing while total still being calculated #48

Closed sethkor closed 5 years ago

sethkor commented 5 years ago

Hello, Is it possible to prevent a bar from completing until the final total is set?

My problem is the code to determine size is slower than the code to process items so the bar completes before I have a chance to set the final total.

In the interim I have worked around by artificially adding an extra item to the total at the start and then subtracting this at the end.

Cheers Seth

vbauerster commented 5 years ago

Hello, Bar never completes if total set to zero.

vbauerster commented 5 years ago

Also fyi, you can trigger complete event manually with SetTotal.

sethkor commented 5 years ago

Sorry I may not have been clear. What I want is for complete event to not trigger if the bars current count equals the total. In order to prevent this from happening now, I increment the total by 1 and then once I know it should complete I decrement total by 1 and set complete to true

vbauerster commented 5 years ago

Doesn't this example suit your needs?