Close a dynamic created threaded query

staffanmw

Member²
Hi,

I create a TOracleQuery in my application like this (i.e. in a click event of a button):

Code:
with TOracleQuery.Create(Application) do try
    Session := OSession;
    Threaded := True;
    SQL.Add('some sql stmt');
    OnThreadExecuted := OQThreadExecuted;
    OnThreadFinished := OQThreadFinished;
    Execute;
  exception
    ShowMessage('something did go wrong ..');
  end;
The code works fine .. but how/when do i call the Free-method? Both the events (executed, finished) are fired okey. If I call the free method in the Finished-event I get a major exception. If I just run the code as above, the application thread count increases each time.

Regards,
Staffan
 
You will have to manage these dynamically created query instances at a higher level in your application, where you can free those instances that are finished.

For your application it may be better to create TThread descendants and create normal query instances that are managed by the thread itself.
 
Thanks! Then I dont need to search any more. Still it would be nice if you could put this as a user request from me to DOA's feature list. I'd prefere a boolean property to free the object when the thread is finish.

Regards,
Staffan
 
Back
Top