Page 1 of 1

Cancelling a Query running in a thread

Posted: 19.01.2010, 04:53
by pawelp
Hi all,
how can I cancel a Zquery, which is opening in an other thread?
The Query opens some quite huge amount of data, which is displayed afterwards in a Grid.
I perform the Zquery.open call inside a separate thread, so my main Form will not be frozen.
But, the user can close this form while the thread is running. I wish to stop the thread and more importantly the Query. Is there any nice way to do it?

Many Thanks
Pawel

Posted: 19.01.2010, 10:34
by seawolf
Which database are you using? I.E. Using firebird SS (not embedded) should be quite simple

Posted: 19.01.2010, 14:39
by pawelp
I'm using Postgres 8.3.9. ZeosLib 6.6.6-stable (from 2009-12-30). Delphi 2007.

Posted: 19.01.2010, 23:18
by seawolf
A solution, not very good, could be:

Add on the uses ZPlainPostgreSqlDriver;

On a procedure
var
PlainDriver: IZPostgreSQLPlainDriver;
begin
...
PlainDriver := IZPostgreSQLPlainDriver(ZConnection1.DbcConnection.GetIZPlainDriver);
PlainDriver.RequestCancel(ZConnection1);
...

Posted: 20.01.2010, 00:38
by pawelp
thanks, I will try it out

Posted: 20.01.2010, 01:22
by pawelp
One small thing so far:
GetIZPlainDriver is undeclared identifier.
But I found the proc GetDriver. I suppose that's the one.

Posted: 08.05.2010, 00:40
by TOLGA
I'm using firebird 2.1 ZeosLib 6.5.6-stable delphi 7
thanks for advice.

Posted: 08.05.2010, 17:13
by seawolf
I think this link and this could help you