Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: AbortJob for a slow TFXQuery or a connection when destroy a Thread


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 1 - Last Post: Jun 2, 2014 3:10 PM Last Post By: Dmitry Arefiev
Pablo Romero

Posts: 21
Registered: 9/28/00
AbortJob for a slow TFXQuery or a connection when destroy a Thread  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 31, 2014 11:55 AM
Hi Fellas!

A have a simple question.

I have a thread that makes some SQL Queries.

I enter on my application, the thread is started and it begins with the SQL queries.

So far, so good.

Some of those SQL Queries are slow. Ok, I want to log-off of my application. On the exit process in my application, I call the thread destructor, like

MyQuery.AbortJob;
MyQuery.Close;
MyQuery.Free;
 
MyConnection.AbortJob;
MyConnection.Close;
MyConnection.Free;


And the application freezzes on MyConnection.Close;

And the Thread is never destroyed, my application never exists and...problems.

My thread is writen ok: it starts with
  inherited create( false )
  FreeOnTerminate := false;


and it's freed in the main form FormClose.

Any ideas?

Regards,

Pablo Romero
Cordoba, Argentina
Dmitry Arefiev

Posts: 1,406
Registered: 12/7/03
Re: AbortJob for a slow TFXQuery or a connection when destroy a Thread  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 2, 2014 3:10 PM   in response to: Pablo Romero in response to: Pablo Romero
Try to use AbortJob(True).

When AWait argument is False, then AbortJob exits without waiting when the command will be really aborted. So, when you calls Close & Free from other thread, command may be still processing. And that may lead to the issues. In general, call only AbortJob from a thread different from processing thread. And move Close & Free into processing thread.

--
With best regards,
Dmitry Arefiev / FireDAC Architect
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02