question

Upvotes
Accepted
5 2 2 4

Cannot instantiate AdxRtList when using COINIT_MULTITHREADED

I'm using the AdfinXRt Realtime example C++ project, and have changed the COM initialisation call in ListDlg.cpp from CoInitialize(0) to CoInitializeEx(NULL, COINIT_MULTITHREADED), to reflect how I intend to use this API in my application. However, the example no longer works because the call to a_eikonDesktopDataAPI->CreateAdxRtList() in AdxRtList.cpp now returns a null COM pointer. Is it possible to use the COM API in the COINIT_MULTITHREADED mode?

eikoneikon-com-apic++
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

· Write an Answer
Upvotes
Accepted
39.4k 77 11 27

Hi @Tristan,

All Eikon COM APIs are implemented using STA (single-threaded apartment) model. They cannot be used in a multi-threaded apartment. To use Eikon COM APIs in your project you need to dedicate a thread, which will house all Eikon COM objects your application creates. Because Eikon COM libraries are implemented as reg free COM, these objects will only be accessible from the thread on which they were created.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.