CoInitializeEx Multithreaded

Post Reply
txemi
Posts: 7
Joined: Fri Jun 29, 2007 11:46 am

CoInitializeEx Multithreaded

Post 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?
beckdo
Posts: 520
Joined: Tue Jan 02, 2007 2:02 pm

Re: CoInitializeEx Multithreaded

Post 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.
Post Reply