SergioFeitoza Posted April 18, 2020 Share Posted April 18, 2020 Hi. Suppose I have a code running and doing a calculation that take some time. What should I include in the event of a “PAUSE” uniButton if I wanted to pause the execution and , if clicking again, to re-start the execution ? And, if the button is a STOP EXECUTION, what should I include ? Thanks in advance Quote Link to comment Share on other sites More sharing options...
SergioFeitoza Posted April 20, 2020 Author Share Posted April 20, 2020 Hi ... Can anyone help me on this ? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted April 20, 2020 Share Posted April 20, 2020 Hi, Sorry, can you tell in more detail what kind of calculation you are talking about? Quote Link to comment Share on other sites More sharing options...
SergioFeitoza Posted April 20, 2020 Author Share Posted April 20, 2020 Hi Sherzod Just to serve as an example suppose that I have a simple loop like below and I click a button to start the calculation of Z but , it takes more than lets say 1 second I want to Stop or to Pause clicking another button LongCalculation(Sender: TObject); begin x:=1; y:= 2; while Z < 10000000000000000 do begin Z := X + Y; X := X +0.1; Y := Y + 0.1; End; Today, in VCL I do like this to stop the loop. Maybe there is something simpler: ……. CancelExecution:= false; for ptsTime := 1 to ptsTimeMax try while ptsTime <=ptsTimeMax do begin try while ptsTime <=ptsTimeMax do begin Application.ProcessMessages; if CancelarExecucao then begin ShowMessage ('Operation cancelled by the user.'); Break; // Sai do loop end; end; Finally formCancelExecution.Close; end; ///////////////////////// procedure TformCancelExecution.BTNCancelExecutionClick(Sender: TObject); begin F0D.CancelaExecution := true; end; Quote Link to comment Share on other sites More sharing options...
Freeman35 Posted April 21, 2020 Share Posted April 21, 2020 Just idea, add frame or panel and maximize it. add css this class and make it transparent (opacity) add button on this, for break your loop. after break or finish loop, remove or hide frame or panel. I mean make a magic or easy for use https://sdkcarlos.github.io/sites/holdon.html Quote Link to comment Share on other sites More sharing options...
SergioFeitoza Posted April 21, 2020 Author Share Posted April 21, 2020 Thankyou but I did not understand . I need somehing easier to do Quote Link to comment Share on other sites More sharing options...
Freeman35 Posted April 22, 2020 Share Posted April 22, 2020 On 4/20/2020 at 11:50 PM, SergioFeitoza said: LongCalculation(Sender: TObject); begin x:=1; y:= 2; while Z < 10000000000000000 do begin Z := X + Y; X := X +0.1; Y := Y + 0.1; End; Today, in VCL I do like this to stop the loop. Maybe there is something simpler: ……. CancelExecution:= false; //--> Show Panel here, panel aling client for ptsTime := 1 to ptsTimeMax try while ptsTime <=ptsTimeMax do begin try while ptsTime <=ptsTimeMax do begin Application.ProcessMessages; if CancelarExecucao then begin ShowMessage ('Operation cancelled by the user.'); Break; // Sai do loop end; end; Finally formCancelExecution.Close; // --> Hide Panel here end; ///////////////////////// // --> This button be on Panel procedure TformCancelExecution.BTNCancelExecutionClick(Sender: TObject); begin F0D.CancelaExecution := true; end; When show Panel, and its Alignment is Client, and it has a cancel button. EndUser have to click & break loop or have to wait finish loop Quote Link to comment Share on other sites More sharing options...
SergioFeitoza Posted April 22, 2020 Author Share Posted April 22, 2020 Hi Freeman35 Thank you for the help. I understood and will implement it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.