Threads + DB + GUI = Trouble!!
>> In multi-threaded applications (and I am working with one over a
>> need to create your sessions, one for every thread, and connect databases
I had the same problem in the beginning, when I used a single TSession
>> those sessions. Every thread HAS TO HAVE its own session.
>My problem is with the GUI (Main) thread - My DBGrid is not stable -
>enter the DBGrid it refreshes and changes the view. Another problem is
>changing while the user is in edit mode on the table.
>But thank u for the advise I'll try it.
object. Then I asked Borland for help, and they said that i "Have to use
separate session for every thread". So, I did it. And now it works just
When you're using a single session, (maybe even the same TTable object),
multiple threads access the same resources, and that is what shouldn't
happen. Even variable access has to be inside critical sections when
I am working with one major application for three years now (over a year
using delphi 3): over 160 data input forms with more than 200 different
tables, more than 300.000 lines of my code. It is a Client/Server based
application, uses background data processing (so users can input data
when data processing is in progress). I'm using two sessions: one for
input, and the other for the background process, and have no problems
DBGrid or any other VCL component.
If you wrote your own auto-refresh routines, there could be the next
problem. If you call refresh for any master table, all detail tables
the same master, or a master from that master, are refreshed too. If in
state, the detail table automatically goes to Browse state.