Hi all,
I've got a reporting service set up (no UI), that accepts requests via TIdHTTP, uses ADO to retrieve data from our database, and then generates an Excel file which is saved.
The problem I have is when somebody wants to cancel a big report. Each request starts up a thread that instantiates the appropriate report class (a descendant of TMyReport) and the TMyReport object does all the work. The thread is there to allow multiple reports to be run at once. I can have the thread set the TMyReport.Cancel property, which I can check periodically during the report generation, but most of the time is spent opening the TADOQuery request - some reports may take 30 minutes or more on this step.
I've read that I can set TADOQuery to run asynchronously, but I'm not sure how to do this appropriately. My guess is that TMyReport starts up it's own thread for each TADOQuery request, then sits in a loop waiting for the TADOQuery to finish, or if it's Cancel property is set to True. If that's the case, do I do something like
I'm not sure what best practice is here. Any thoughts are appreciated.
Thanks,
Griffyn
I've got a reporting service set up (no UI), that accepts requests via TIdHTTP, uses ADO to retrieve data from our database, and then generates an Excel file which is saved.
The problem I have is when somebody wants to cancel a big report. Each request starts up a thread that instantiates the appropriate report class (a descendant of TMyReport) and the TMyReport object does all the work. The thread is there to allow multiple reports to be run at once. I can have the thread set the TMyReport.Cancel property, which I can check periodically during the report generation, but most of the time is spent opening the TADOQuery request - some reports may take 30 minutes or more on this step.
I've read that I can set TADOQuery to run asynchronously, but I'm not sure how to do this appropriately. My guess is that TMyReport starts up it's own thread for each TADOQuery request, then sits in a loop waiting for the TADOQuery to finish, or if it's Cancel property is set to True. If that's the case, do I do something like
Code:
QueryThread.Start;
repeat
Sleep(100);
until QueryThreadHasFinished or ReportIsCancelled;
I'm not sure what best practice is here. Any thoughts are appreciated.
Thanks,
Griffyn