Threads + DB + GUI = Trouble!! 
Author Message
 Threads + DB + GUI = Trouble!!

Quote:

>> In multi-threaded applications (and I am working with one over a

year),
you
Quote:
>> need to create your sessions, one for every thread, and connect

databases
to

Quote:
>> those sessions. Every thread HAS TO HAVE its own session.

>My problem is with the GUI (Main) thread - My DBGrid is not stable -
when I
>enter the DBGrid it refreshes and changes the view. Another problem is
records
>changing while the user is in edit mode on the table.
>But thank u for the advise I'll try it.

I had the same problem in the beginning, when I used a single TSession
object. Then I asked Borland for help, and they said that i "Have to use
a
separate session for every thread". So, I did it. And now it works just
fine
:)

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
writing
multi-threaded applications.
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
even
when data processing is in progress). I'm using two sessions: one for
data
input, and the other for the background process, and have no problems
with
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
using
the same master, or a master from that master, are refreshed too. If in
Edit
state, the detail table automatically goes to Browse state.

Danijel Tkalcec,
DeltaSoft.



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Multi Thread + GUI + DB = TROUBLE!

2. Background thread writing to DB - dealing with app shutdown

3. Converting from DB to SQL Server gives me trouble

4. Business logic separated from GUI?

5. Need help to smoothly display GUI!

6. GUI in graphic DOS and binary file

7. setrgb10.zip GUI Utility to choose values for SetRGBPallete Procedure

8. GUI with freepascal

9. GUI and FreePascal...

10. How do i develop GUI?

11. Options for GUI development using FPC

12. Making a GUI with BP 7.0

 

 
Powered by phpBB® Forum Software