Multi Thread + GUI + DB = TROUBLE! 
Author Message
 Multi Thread + GUI + DB = TROUBLE!

I am writing a multi threaded application with a few threads writing at
the same time to the same table. The main (GUI) thread is one of them -
using a  DBGrid component. what to I do to prevent the threads
intefiring with each other. I tried TCriticalSection but it is not
sutible for the GUI part.
I am working with delphi 3 on Win95 with Paradox DB.


Wed, 18 Jun 1902 08:00:00 GMT  
 Multi Thread + GUI + DB = TROUBLE!

Erwin Denissen heeft geschreven in bericht ...

Quote:

>Avi Jencman heeft geschreven in bericht

>>I am writing a multi threaded application with a few threads writing at
>>the same time to the same table. The main (GUI) thread is one of them -
>>using a  DBGrid component. what to I do to prevent the threads
>>intefiring with each other. I tried TCriticalSection but it is not
>>sutible for the GUI part.
>>I am working with Delphi 3 on Win95 with Paradox DB.

>You have to use a different TSession for every Thread.

>Good luck,

>Erwin Denissen at
>http://www.high-logic.com/

>** providing shareware components with source **



Wed, 18 Jun 1902 08:00:00 GMT  
 Multi Thread + GUI + DB = TROUBLE!

Quote:

> I am writing a multi threaded application with a few threads writing
> at
> the same time to the same table. The main (GUI) thread is one of them
> -
> using a  DBGrid component. what to I do to prevent the threads
> intefiring with each other. I tried TCriticalSection but it is not
> sutible for the GUI part.
> I am working with Delphi 3 on Win95 with Paradox DB.

Indeed, you should use a TSession for every thread. But, i never hadany
succes in writing a reliable app with it. Instead, you better
cache your data for the threads and read/write to the database
in the main thread.

Ruud Vlaming.



Wed, 18 Jun 1902 08:00:00 GMT  
 Multi Thread + GUI + DB = TROUBLE!

Quote:
>Indeed, you should use a TSession for every thread. But, i never hadany
>succes in writing a reliable app with it.

each thread needs his own tsession and tdatabase. works reliable but
eats licenses :-)

Quote:
>cache your data for the threads and read/write to the database
>in the main thread.

we use a sql-thread to exec the long running queries (sps)


Wed, 18 Jun 1902 08:00:00 GMT  
 Multi Thread + GUI + DB = TROUBLE!
I tried using a TSession for each thread but that made the GUI unstable -
The DBGrid changes each time the user tries to write something?
Quote:

> Erwin Denissen heeft geschreven in bericht ...

> >Avi Jencman heeft geschreven in bericht

> >>I am writing a multi threaded application with a few threads writing at
> >>the same time to the same table. The main (GUI) thread is one of them -
> >>using a  DBGrid component. what to I do to prevent the threads
> >>intefiring with each other. I tried TCriticalSection but it is not
> >>sutible for the GUI part.
> >>I am working with Delphi 3 on Win95 with Paradox DB.

> >You have to use a different TSession for every Thread.

> >Good luck,

> >Erwin Denissen at
> >http://www.high-logic.com/

> >** providing shareware components with source **



Wed, 18 Jun 1902 08:00:00 GMT  
 Multi Thread + GUI + DB = TROUBLE!
Just idea .... did you try use Synchronize() to synchronize writing to main
thread.

Jan Najvarek

Quote:

>I tried using a TSession for each thread but that made the GUI unstable -
>The DBGrid changes each time the user tries to write something?


>> Erwin Denissen heeft geschreven in bericht ...

>> >Avi Jencman heeft geschreven in bericht

>> >>I am writing a multi threaded application with a few threads writing at
>> >>the same time to the same table. The main (GUI) thread is one of them -
>> >>using a  DBGrid component. what to I do to prevent the threads
>> >>intefiring with each other. I tried TCriticalSection but it is not
>> >>sutible for the GUI part.

.................


Wed, 18 Jun 1902 08:00:00 GMT  
 Multi Thread + GUI + DB = TROUBLE!
The problem is that the DBGrid is connected directly to the table so there is no
place to call Synchronize (or use a Critical section for that matter)
Quote:

> Just idea .... did you try use Synchronize() to synchronize writing to main
> thread.

> Jan Najvarek


> >I tried using a TSession for each thread but that made the GUI unstable -
> >The DBGrid changes each time the user tries to write something?


> >> Erwin Denissen heeft geschreven in bericht ...

> >> >Avi Jencman heeft geschreven in bericht

> >> >>I am writing a multi threaded application with a few threads writing at
> >> >>the same time to the same table. The main (GUI) thread is one of them -
> >> >>using a  DBGrid component. what to I do to prevent the threads
> >> >>intefiring with each other. I tried TCriticalSection but it is not
> >> >>sutible for the GUI part.
> .................



Wed, 18 Jun 1902 08:00:00 GMT  
 Multi Thread + GUI + DB = TROUBLE!
1.) Every thread has to have it's own session, or it doesn't work properly.
2.) All VCL calls have to be synchronised when calling from a thread.




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

 Relevant Pages 

1. Threads + DB + GUI = Trouble!!

2. Multi Threads accessing the same database

3. Multi-thread with tsession and tquery

4. D3/BDE multi-threaded apps : Anyone done it ?

5. multi threading in fpc linux?

6. Multi threading the BDE (and killing queries)

7. Multi threading

8. Multi-Threading MIDAS

9. Multi-thread and Oracle 7 on Delphi (version 2 or 3)

10. Multi-threading queriy problem

11. multi-threaded querying approach

12. multi-thread unit for TP7

 

 
Powered by phpBB® Forum Software