I need to show a popup window before a query execution, show the time elapsed while the sql query is being executed, and close that window when the query ends.
Actually I do something like this
var
frm : tFrmPopupElapsed;
// this form has a TTimer and a TLabel to show the elapsed time
// but the label is not updated, I tried using update and refresh
// but nothing happens
begin
frm := tFrmPopupElapsed.Create(nil);
try
frm.Init; // this procedure enables the timer
frm.Show();
ExecuteMyVeryLongQuery();
finally
frm.Close;
end;
end;
How can the label be updated to show the elapsed time while the query executes? Using a timer? Or a thread?
You need to run the query asynchronously, allowing you to update the Form in the meantime.
The simplest way to do it without getting your hands dirty with the threads is to use Andreas Hausladen's AsynCalls library.
You can also give a look at the OmniThread Library by Primoz Gabrijelcic.
You will need to run the query in a background thread if you want the user interface to be responsive during the query execution. If the query supports cancellation, you could also add a cancel button. I believe only ADO queries support this, however.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With