07-04-2025, 05:41 AM
Hi Alexandre,
I have a follow-up question regarding this... I understand that IIS is using a threadpool with threads that are already COM-initialized to handle the incoming ISAPI DLL requests. So that works fine.
However, what about threads that we create ourselves within the ISAPI DLL? For example, in order to fulfill a request, we create new threads or tasks in our Delphi code, and let them use a data module from the data module pool or perform other operations that require COM initialization to be set.
We assume we need to call CoInitialize (and UnCoInitalize) in these cases.
My question is: are we correct? Should we call CoInitialize(nil)? Or perhaps CoUnInitialize(0, COINIT_MULTITHREADED) instead? Or nothing at all? (I assume threads we create manually inside the ISAPI DLL are not taken from the IIS threadpool).
Groetjes, Bob Swart
PS: When I check the IntraWeb source code unit IWServerControllerBase, I see that CoInitialize or CoUnitialize are not called when the ComInitialization property is set to ciNone (which it is in our ISAPI DLL), which covers the incoming requests handled by threads from the application pool. I see no other calls to CoInitialize...
I have a follow-up question regarding this... I understand that IIS is using a threadpool with threads that are already COM-initialized to handle the incoming ISAPI DLL requests. So that works fine.
However, what about threads that we create ourselves within the ISAPI DLL? For example, in order to fulfill a request, we create new threads or tasks in our Delphi code, and let them use a data module from the data module pool or perform other operations that require COM initialization to be set.
We assume we need to call CoInitialize (and UnCoInitalize) in these cases.
My question is: are we correct? Should we call CoInitialize(nil)? Or perhaps CoUnInitialize(0, COINIT_MULTITHREADED) instead? Or nothing at all? (I assume threads we create manually inside the ISAPI DLL are not taken from the IIS threadpool).
Groetjes, Bob Swart
PS: When I check the IntraWeb source code unit IWServerControllerBase, I see that CoInitialize or CoUnitialize are not called when the ComInitialization property is set to ciNone (which it is in our ISAPI DLL), which covers the incoming requests handled by threads from the application pool. I see no other calls to CoInitialize...

