I have a COM server and a COM client, both written with ATL7.
In the server, I need to keep a list of all the objects created and under particular situations fire events to these objects.
At the moment, in the FinalConstruct of the object, I keep the 'this' pointer in an array.
Then in another part of the code, when a receive a message from another application, I iterate throught the array and call the OnEvent method create by ATL to fire the event.
This work fine if the FinalConstruct and the location where I fire the event are in the same thread but as it happends, my application is multithreaded and the thread firing the event is not the same thread as the thread that created the object, so I get a 0x8001010E error code.
Given that I have the pointer to the object, what can I do to fire my event in the second thread?