Topic: AnyDAC in DLL
|
|
knulo
User
 Senior Boarder
| Posts: 38 |   | Karma: 1 |
|
AnyDAC in DLL
|
|
Posted: 2007/06/22 02:04 |
|
|
|
|
Hello Dmitry,
I have to use AnyDAC from within a dynamically linked DLL (BCB5). I have a TDataModule with TADConnection, TADQuery, physical links and TADWaitCursor. While disconnecting the DLL I got 'ADManager timeout exception'. I do close all queries and the connection before unload DLL. If I put code like in the routine closing the connection there is a compiler error "must have pointer on left side of structure" - ADManager not known?. Also I read http://www.da-soft.com/component/option,com_joomlaboard/Itemid,/func,view/catid,4/id,10496/#10496 but unfortunatly your little example is no longer available for download. What have I to do to avoid the exception? Can you give me the example for further resarch?
Thanks in advance and regards,
Knut
Post edited by: knulo, at: 2007/06/22 02:13
Post edited by: knulo, at: 2007/06/22 02:47
|
|
knulo
User
 Senior Boarder
| Posts: 38 |   | Karma: 1 |
|
Re:AnyDAC in DLL
|
|
Posted: 2007/06/22 02:17 |
|
|
|
|
After I put TADManager on TDataModule and call before releasing DLL, everything works fine.
Seems like component TADManager is required explicit and not only implicit by dropping TADConnection on a form.
So far so good. But: now application stays in memory after ending. And now? Any suggestions?
Regards
Knut
Post edited by: knulo, at: 2007/06/22 02:50
|
|
knulo
User
 Senior Boarder
| Posts: 38 |   | Karma: 1 |
|
Re:AnyDAC in DLL
|
|
Posted: 2007/06/22 04:48 |
|
|
|
|
Hello Dmitry!
Now I put
ADConnection1->Close();
Application->ProcessMessages();
ADManager1->Close();
Sleep(1000); // (1) without that, application hang on close
ADManager1->Free();
|
in my routine closing connections. It seems to solve the problem, but the line (1) is time critical and the value of one second may be not right for different environment (other database connection). So I think, that it is no good ("water-proof") solution. Can you give me an advise to make it better, please?
Thanks in advance,
regards Knut
Post edited by: knulo, at: 2007/06/22 04:49
|
|
Diman
Admin
 Admin
| Posts: 1509 |  | Karma: 20 |
|
Re:AnyDAC in DLL
|
|
Posted: 2007/06/22 07:10 |
|
|
|
|
Hello Knut
I put DLL.ZIP again at www.da-soft.com/dmdocuments/DLL.ZIP. The main idea - you should create exported from DLL procedure, which will explicitly close ADManager.
Regards, Dmitry
|
|
knulo
User
 Senior Boarder
| Posts: 38 |   | Karma: 1 |
|
Re:AnyDAC in DLL
|
|
Posted: 2007/06/25 10:11 |
|
|
|
|
Hello Dmitry,
sorry, but this link is broken: 'requested file does not exist'. Would you be so kind and check it again? Thanks.
Regards Knut
|
|
Diman
Admin
 Admin
| Posts: 1509 |  | Karma: 20 |
|
knulo
User
 Senior Boarder
| Posts: 38 |   | Karma: 1 |
|
Re:AnyDAC in DLL
|
|
Posted: 2007/06/27 02:26 |
|
|
|
|
Hello Dmitry,
O.K., your example does it in a similar way as I do, except that I have to- put a wait time after ADManager->Close() and
- after that I have to free ADManager explicitly
to force termination of my application. Without that, application doesn't terminate (window disappears but stays in memory). Once again: the wait time value is just a guess and there is no certainty that it works in either environment. So I'm looking for a proofer way to do that. Now I tested this:
Step = 0;
while (ADManager1->Active)
{
if (!Step)
ADManager1->Close();
Sleep(1);
Step++;
Application->ProcessMessages();
}
|
And: Heureka - it works! Surprisingly needs only one loop. No longer need to free ADManager.
I run application on Windows-XP client, database is on Linux server.
Can you explain to yourself this behaviour? Or can you observe that in your environment?
Nevertheless: I can live with this solution and hope it helps other guys with similar issues.
Regards,
Knut
Post edited by: knulo, at: 2007/06/27 05:51
|
|
|