i am working on the COM out of proc server. previously i had designed my COM
server with singleton object but based on the very good response
"http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/83a8de4b-a7a6-46c0-bb40-37f67e5c3c3d"
in MSDN forum i changed it to used same global class. now i would like to
know how could i send events from global class to the COM objects with
connection point.
here is the problem.
i have a class called CGlobalClass g_Globalclass in side the ATL service.
it has a method which takes a long time say init().
i also added a ATL simple Object ( ITestObj ) which impelemnts Connection
points and a method "Fire_Done"
//for simplicity i have removed error checking code.
//COM Method call..
CtestObj::Init()
{
//just call global function
return g_Globalclass.Init();
}
void CGlobalclass::Init()
{
CreateThread(ThreadFun)
return E_PENDING;
}
CGlobalclass::ThreadFun(LPPARAM )
{
//Long processing
//Now how to call CTestObj's connection points function.
}
what i am thinking is like this that when clients would setup the connection
point it would call
Advise/Unadvise. i need to save (those marshalled interface (GDT) )it into a
global class. that i could access into this cGlobalClass.
is my approach correct? does it make sense or you have any other suggestion
--
d
Have those COM objects register themselves with the singleton class. The singleton would call some method (not necessarily a COM method, could use a regular C++ method) on COM objects, which in turn would fire an event on their attached event sinks.
> void CGlobalclass::Init()
> {
> CreateThread(ThreadFun)
> return E_PENDING;
> }
>
> CGlobalclass::ThreadFun(LPPARAM )
> {
> //Long processing
>
> //Now how to call CTestObj's connection points function.
> }
For suggestions on firing events from a worker thread, see http://vcfaq.mvps.org/com/1.htm
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not necessarily a good idea. It is hard to be sure where they are going to land, and it could be dangerous sitting under them as they fly overhead. -- RFC 1925
Have you made any progress? Do you have any outstanding questions?
Brian