O/H Rob Kennedy έγραψε:
>
>
> ianhinson wrote:
> > I ran accesses against a global ADO connection in a number of threads
> > such that the accesses would occur simultaneously, or at least would
> > overlap (this was a test program just to see if or how ADO would
> > handle it), with each thread recording the time it started
> > and completed and needing to iterate through a large table for the
> > sake of taking up some time to cause overlap.
>
> ADO is all based on COM, right? Have you remembered to call CoInitialize
> in all your threads? Have you created the COM object using a threading
> model that allows you to use it from multiple threads? (I think that means
> using free threading.)
>
> --
> Rob
ianhinson
create, initialize and open a separate
connection instance for each of your threads,
from INSIDE the Execute()'s method. Don't let your threads
to share a single connection even if you "synchronize" it.
Even though the ADO subsystem is thread-safe (is it really?)
you can not tell the same for the database server's client library.
In fact there is not such a thread-safe client library.
So, it's better to have a connection per thread.
And, as Rob suggested to you, don't forget to call
CoInitialize(nil).
procedure TMyThread.Execute;
begin
CoInitialize(nil);
try
try
// create a connection here
except
end;
finally
CoUnInitialize;
end;
end;
--
Regards
Theo
------------------------
Theo Bebekis
Thessaloniki, Greece
------------------------
Greek_Delphi_Prog : a Delphi Programming mailing list in Greek at
http://groups.yahoo.com/group/Greek_Delphi_Prog
CSharpDotNetGreek : A C# and .Net mailing list in Greek language at
http://groups.yahoo.com/group/CSharpDotNetGreek
atla_custom : a Unisoft Atlantis Customization mailing list at
http://groups.yahoo.com/group/atla_custom
------------------------
-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: [EMAIL PROTECTED]
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/delphi-en/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/delphi-en/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:[EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/