Page 1 of 1

CoInitializeEx Multithreaded

Posted: Fri Jun 29, 2007 12:15 pm
by txemi
Hi.

I am developing a DLL to handle Optitrack camera model flex c:120.

Due to the use of other libraries, I am forced to initialize the COM objects using CoInitializeEx(NULL, COINIT_MULTITHREADED); instead of CoInitialize(NULL);

This causes a memory exception when calling the GetFrameImage function of INPCamera.

I get the same behaviour when modify the "GrayscaleSample".

Code: Select all

......

int main()
{
   //== Initialize Microsoft COM Interop ===============----
   //CoInitialize(NULL);
   HRESULT hResult = CoInitializeEx(NULL, COINIT_MULTITHREADED);
   //HRESULT hResult = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);

......

I check in the specs about the threading issues, and it states that apartment threaded is needed (actually the before example worked fine when using
(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED)). Is there any way I can use the COM as MULTITHREADED?

Re: CoInitializeEx Multithreaded

Posted: Mon Jul 02, 2007 3:14 pm
by beckdo
I believe that multithreaded apartment is required for the OptiTrack SDK and attempting to using it in multithreading mode will likely cause it to crash unfortunately.