|
Multi Thread aplication
|
Joined: Sep 2000
Posts: 3 Brasilia, DF, Brazil
Member
|
OP
Member
Joined: Sep 2000
Posts: 3 Brasilia, DF, Brazil |
|
|
|
Re: Multi Thread aplication
|
Joined: Aug 1999
Posts: 22,218
Member
|
Member
Joined: Aug 1999
Posts: 22,218 |
When exactly does this error occur? Have you set TOracleSession.ThreadSafe to True?
------------------ Marco Kalter Allround Automations
Marco Kalter Allround Automations
|
|
|
Re: Multi Thread aplication
|
Joined: Sep 2000
Posts: 3 Brasilia, DF, Brazil
Member
|
OP
Member
Joined: Sep 2000
Posts: 3 Brasilia, DF, Brazil |
Marco,
First of all, sorry for my english ... I have tried this simple test program ... I tried with ThreadSafe = True and ThreadSafe = False, but the errors it seems to be aleatory. I can
|
|
|
Re: Multi Thread aplication
|
Joined: Aug 1999
Posts: 22,218
Member
|
Member
Joined: Aug 1999
Posts: 22,218 |
Perhaps you can send me a complete demo project by e-mail?
------------------ Marco Kalter Allround Automations
Marco Kalter Allround Automations
|
|
|
Re: Multi Thread aplication
|
Joined: Sep 2000
Posts: 3 Brasilia, DF, Brazil
Member
|
OP
Member
Joined: Sep 2000
Posts: 3 Brasilia, DF, Brazil |
|
|
|
Re: Multi Thread aplication
|
Joined: Sep 2000
Posts: 35 Lund, Sweden
Member
|
Member
Joined: Sep 2000
Posts: 35 Lund, Sweden |
You should call inherited Create (the first thing you do) in your constructor.
/ David
|
|
|
Re: Multi Thread aplication
|
Joined: Nov 2001
Posts: 1 Houston, TX, USA
Member
|
Member
Joined: Nov 2001
Posts: 1 Houston, TX, USA |
Marco, Has this been resolved? I am experiencing similar problems. I have a server that uses HTTP to handle multiple client requests. Each request is handled on a separate thread. I am using a common ThreadSafe session for all of the threads, but anytime I have two threads attempting to Connect the session at the same time, I get either an EORacle error or an EExternalError.
This is a very critical problem for us to resolve.
Thanks, Will
[quote]Originally posted by mkalter: Perhaps you can send me a complete demo project by e-mail?
[/quote]
Thanks, Will
|
|
|
Re: Multi Thread aplication
|
Joined: Aug 1999
Posts: 22,218
Member
|
Member
Joined: Aug 1999
Posts: 22,218 |
Two threads are connecting the same session? That might indeed cause problems. You should probably connect and disconnect this common session in the main thread, and only perform database access in the threads.
You should preferably use a session instance per thread though. If you use one session, all database access operations from different threads will be serialized. A session can only perform one operation at a time.
------------------ Marco Kalter Allround Automations
Marco Kalter Allround Automations
|
|
|
Re: Multi Thread aplication
|
Joined: Sep 2001
Posts: 33
Member
|
Member
Joined: Sep 2001
Posts: 33 |
If I need to use more than one session, I usually create a small pool of say 5 or so sessions. I add them to a TList descendent stored in a private variable within the main module of the application. You can either use them at random, or, more efficiently, prioritize them. Allocate the first two to GUI queries, and the rest to queries. You can even do a neat trick like pull them from the "available pool" into an "in use pool", then put them back as they are not used anymore. I would definitely connect them all up front, and leave them connected for the duration of the application.
|
|
|
Re: Multi Thread aplication
|
Joined: Mar 2000
Posts: 64
Member
|
Member
Joined: Mar 2000
Posts: 64 |
I had similar problems and solved it with a global critical section around the LogOn() and LogOff() when doing it from a couple of threads at the same time. Don't know if it's the right fix...
juergen
|
|
|
|
|
|