How to implement a Thread to allow cancellation of Stringgrid fill in Delphi?

Asked

Viewed 108 times

1

I load spreadsheets in a Stringgrid and then insert them in the bank, wanted a thread to allow to cancel this import, that is to cancel the completion of stringGrid, the button is "Inclicavel" as you already know, until the completion of the filling. Detail, I show this Rectangle and a progression just for the user to follow. And he won’t be able to touch the system while it matters, he can just cancel Does anyone have any idea how I can make this thread to fill in Stringgrid?

Quero uma thread para permitir clicar no cancelar para interromper o preenchimento de uma stringGrid

1 answer

1


You must be using some repeating structure for the right fill?

If it is while, for... you can implement a Break.

for i := 0 to Pred(Registros.Count) do
begin
  if (vCancelar = True) then {seria definida como True no click do botão cancelar}
  begin
    Break;
  end;
end;

If you’re riding a DataSet then position it at the end of the Records.

About the Button being "tiltable" is failure of your application, as I imagine you are using a repeat structure, whatever, ALWAYS at the beginning or at the end of any add iteration:

Application.ProcessMessages;

This way the application can breathe while the processor runs the methods at home iteration.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.