Subject | Connectiong in a thread |
---|---|
Author | DanyM |
Post date | 2011-11-29T14:39:03Z |
I would like my GUI application to use a separate thread to connect to the database (FB 2.0, FB 2.1). I have seen this done in other environments with FireBird.
The idea is to show a "Connecting..." dialogue/window in which the user may abort the operation at *any* time instantaneously. The connecting thread would then be aborted. An animation may be shown during the phase where the connecting thread is waiting for the FB client library and the main thread with the window may receive windows messages normally.
In most Delphi + fbclient application I see the application is totally unresponsive during connection and the annoying thing is for the user to wait for the time out. I do not want to change the time out.
This application already has a ConnectionDataModule with session and connection component. The module is referenced by a lot of datamodules after a successful connect. It is written so that in the (near) future I might decide to provide each datamodule with it's own ConnectionDataModule. But this is a bit besides the point at the moment.
My problem is that my delphi+threading expirience is a little meagre, though I have used threads both in applications and in services, so I'm not asking for the basics.
One approach that I'm thinking about is to create a connection thread and let that thread create the ConnectionDataModule. If things fail or are aborted the thread should exit and return an error to the main thread. If things go well, however I would ideally like the thread to "hand over" the complete datamodule object with all the state data to the main thread.
Is this even possible? Does anyone have any idea of how to go about this task?
TIA,
/Dany
The idea is to show a "Connecting..." dialogue/window in which the user may abort the operation at *any* time instantaneously. The connecting thread would then be aborted. An animation may be shown during the phase where the connecting thread is waiting for the FB client library and the main thread with the window may receive windows messages normally.
In most Delphi + fbclient application I see the application is totally unresponsive during connection and the annoying thing is for the user to wait for the time out. I do not want to change the time out.
This application already has a ConnectionDataModule with session and connection component. The module is referenced by a lot of datamodules after a successful connect. It is written so that in the (near) future I might decide to provide each datamodule with it's own ConnectionDataModule. But this is a bit besides the point at the moment.
My problem is that my delphi+threading expirience is a little meagre, though I have used threads both in applications and in services, so I'm not asking for the basics.
One approach that I'm thinking about is to create a connection thread and let that thread create the ConnectionDataModule. If things fail or are aborted the thread should exit and return an error to the main thread. If things go well, however I would ideally like the thread to "hand over" the complete datamodule object with all the state data to the main thread.
Is this even possible? Does anyone have any idea of how to go about this task?
TIA,
/Dany