Hello everyone
Grateful for the interest and for some comment that they make me arrive to solve the following:
I want to implement, that the value property of a ProgressBar is going to UPDATE as it advances the LOOP that can be For or a While and also has the possibility of clicking on a button called cancel and can finish a process.
I tried to put the loop inside the Thread but I did not get it, but at the same time it complicates me a bit, because I suppose for each process I need a Thread and there are several processes.
Cordially,
Raul Juarez Pulache
But you may need to use a thread or keep status in variables and do. next step each time the timer fires.
Somehow give time for redrawing
Raul, I don’t recommend you to use a button to cancel a loop, because probably the button actions is never fired. Instead I suggest to change button Caption to " Cancel (Press Esc) and in the loop check for UserCancelled http://documentation.xojo.com/index.php/UserCancelled
[quote=332824:@Raul Juarez Pulache]Hello everyone
Grateful for the interest and for some comment that they make me arrive to solve the following:
I want to implement, that the value property of a ProgressBar is going to UPDATE as it advances the LOOP that can be For or a While and also has the possibility of clicking on a button called cancel and can finish a process.
I tried to put the loop inside the Thread but I did not get it, but at the same time it complicates me a bit, because I suppose for each process I need a Thread and there are several processes.
Cordially,
Raul Juarez Pulache[/quote]
It maybe time you learn how to use a timer, instead of a loop. Loops cannot update the UI anymore.
Basically, here is a regular loop (which does not work for a progressbar):
For i as Integer = 1 to 100
ProgressBar.Value = i
next
- Drag a timer to the window
- Make it’s period zero
- Make it’s mode Off
- In the Action event :
Static i as Integer = 1
If i < 100 then
ProgressBar.Value = i
i = i + 1
else
i = 1
me.mode = Timer.ModeOff
end if
To start the loop, do
Timer1.mode = Timer.ModeMultiple
Thank you so much
Ramon Sastre
Christian Schmitz
Michel Bujardet
As I recommend Ramon, do not use a button to cancel, instead had to put a caption “Cancel (Press Esc)” and use the function UserCancelled and be able to determine if the user pressed escape to finish the process.
With this I can solve my problem
Greetings and blessings
Raul Juarez Pulache