I am trying to get each connection thread in a TIdTCPServer instance to instanciate a TADOConnection into the context.
This works fine, and I place the CoInitialize(nil) in the OnConnect event handler. Problem is it takes around 20-25 seconds for this process to work, which is WAY to long…
Any advice?
Cheers,
Adrian
It is very unlikely that either
CoInitialize()or ADO takes that long to initialize. I have worked with multithreaded COM for years and never experienced such a delay.That being said, a better place to initialize COM is at the top of the calling thread’s
Execute()method rather than in the server’sOnConnectevent. To do that with Indy, derive a new class fromTIdThreadWithTaskand override itsBeforeExecute()andAfterExecute()methods. Then instantiate aTIdSchedulerOfThread...component, assign your class to itsThreadClassproperty, and assign it to the server’sSchedulerproperty before activating the server.