Why I don't need call CoInitialize in a thread created inside a COM Thread?
In order to learn multithreading, I've created a thread inside a COM
Thread (TRemoteDataModule).
This is my Component Factory:
TComponentFactory.Create(ComServer, TServerConn2, Class_ServerConn2,
ciMultiInstance, tmApartment);
Inside the Thread, I didn't needed to Call CoInitialize to use
TADOQuery.Create, .Open... .Exec
I read that I need to initialize the COM library on a thread before you
call any of the library functions except CoGetMalloc, to get a pointer to
the standard allocator, and the memory allocation functions.
But in this case, the absence of CoInitialize didn't brought me any trouble.
Is this related with Thread Model? Where can I Find the explanation for
this subject?
UPDATE:
When I say INSIDE, it means inside the COM method context:
interface
type
TWorkerTread = class(TThread);
TServerConn2 = class(TRemoteDataModule, IServerConn2)
public
procedure Method(); safecall;
end;
implementation
procedure TServerConn2.Method();
var W: TWorker;
begin
W := TWorkerTread.Create(Self);
end;
UPDATE 2:
The TADOConnection used to connect to database are currently being created
in the COM Thread context (TThread.Create constructor). Although,
TADOConnection.Open and TADOQuery.Create/.Open are both being performed
inside TThread.Execute .