Subject | RE: [IBO] IBO components in a thread |
---|---|
Author | Don Schoeman |
Post date | 2006-07-05T06:42:43Z |
Thx for the replies everyone.
I'd just like to re-iterate that there is only one thread ever accessing the
datamodule and the components on the datamodule. No other thread EVER
references these components via any means, not even the main form. The only
way other threads can get data from the "database" thread is via
asynchronous thread safe Queues and Lists. The application has 12 threads
all doing different things and it all worked smoothly until I started doing
more complex queries.
As I thought, the placement of an additional TIB_Session component on the
datamodule didn't make a difference as it litteraly is only one thread ever
doing any kind of data access, hence the single internal session should be
fine. However, I did manage to get a way around this problem, here is what I
did:
Instead of having join statement which joins blob fields into the result
set, I now do multiple queries and then build the data structures locally.
This has the added benefit of less network traffic and also fixes the
problem with IBO crashing. It also speeds up the operation quite a bit since
the XML data in the blob fields are only parsed once before it is passed on
to my local data structures.
I'd still like to know what causes the problem but at least I can now carry
on with my work.
Thx for the help,
Regards,
Don
At 09:55 PM 4/07/2006, you wrote:
Originally you wrote:
first data access object in the creation order of the module), along
with its own TIB_Connection, its own transactions, datasets etc.
As for events - OK - but again, your IB_Events has to be specific to
the session in the thread. It's fine for one thread to listen for
events that another thread might have posted (the world turns upon
such things!) but the callbacks must return to the
session-connection-ibevents that *registers* them.
"Error reading data from the connection" means you've crashed it the
connection, by the way - entirely expected behaviour with your setup. :-)
Helen
[Non-text portions of this message have been removed]
I'd just like to re-iterate that there is only one thread ever accessing the
datamodule and the components on the datamodule. No other thread EVER
references these components via any means, not even the main form. The only
way other threads can get data from the "database" thread is via
asynchronous thread safe Queues and Lists. The application has 12 threads
all doing different things and it all worked smoothly until I started doing
more complex queries.
As I thought, the placement of an additional TIB_Session component on the
datamodule didn't make a difference as it litteraly is only one thread ever
doing any kind of data access, hence the single internal session should be
fine. However, I did manage to get a way around this problem, here is what I
did:
Instead of having join statement which joins blob fields into the result
set, I now do multiple queries and then build the data structures locally.
This has the added benefit of less network traffic and also fixes the
problem with IBO crashing. It also speeds up the operation quite a bit since
the XML data in the blob fields are only parsed once before it is passed on
to my local data structures.
I'd still like to know what causes the problem but at least I can now carry
on with my work.
Thx for the help,
Regards,
Don
At 09:55 PM 4/07/2006, you wrote:
>Just another note, I've created the same routine which loads the data ina
>standard Delphi app and it works flawlessly, so it must have something todo
>with the threads.It certainly does.
Originally you wrote:
>1)
> > I actually do have other IBO components on the DataModule: They are:
> > TB_SessionProps and 2) TIB_Events. I don't know if any of these twoWhat you need for *each thread* is its own TIB_Session object (as the
> could
> > perhaps cause a problem?
first data access object in the creation order of the module), along
with its own TIB_Connection, its own transactions, datasets etc.
As for events - OK - but again, your IB_Events has to be specific to
the session in the thread. It's fine for one thread to listen for
events that another thread might have posted (the world turns upon
such things!) but the callbacks must return to the
session-connection-ibevents that *registers* them.
"Error reading data from the connection" means you've crashed it the
connection, by the way - entirely expected behaviour with your setup. :-)
Helen
[Non-text portions of this message have been removed]