Subject Re: [IBO] Multi-threaded programs
Author Helen Borrie
At 11:45 PM 22/06/2007, you wrote:
>I need to add a separate thread to one of my programs to allow a long
>running update to take place while the user continues to work in the
>foreground. What is the best way to set up the background thread?
>
>Do I need a separate IB_Connection object for the background thread or
>will a separate IB_Transaction be sufficient?

You need to create a completely isolated structure of an IB_Session,
IB_Connection, IB_Transactions and statements. None should cross
over into other threads, including the main thread.


>Should the IBObjects components for the background thread be in their
>own TDataModule or can the reside in the same TDataModule as the one
>for the foreground thread?

Not. Total isolation. Put all the stuff that will be used by a
thread instance into its own datamodule[s] and have them created and
destroyed per thread. Don't reference *anything* across thread boundaries.

>Anything else that you can recommend that I haven't mentioned?

In case it has slipped you mind, take care that the IB_Session for
the thread is the first thing in the creation order.

Don't use the default IB_Session anywhere in your app. Ensure that
your main thread has its own explicit IB_Session that is created
completely FIRST.

Helen