Originally posted by: Veeraiah k
Hai,
I developed one component DLL using ATL connection point mechanism for ascynchronus notification(Just same as theone from article1 in CODEGURU.COM/ATL.I used VB as client.After that i made as stand alone exe.I opened two instances of exe (in the same machine as well as in the other machine after registering dll)
Now notification giving to the one instance only(means not ascynchronus notification).Not to other instances.
What shall i do to get notification in other instances also(Multiple clients).
please reply me.
regards,
veeru
Reply
Originally posted by: Veeraiah koritela
Thank you very much
Hai Asish,
I went through your both articles I & II .I just followed the steps given in your articles and really worked out for me.
Expecting more articles from you in future too.
With warm Regards,
veeru
Reply
Originally posted by: Tony
I've been experimenting with custom callback interfaces like the one you present here. I've found the problems start when you have multiple clients handing their callback i'face pointers to a single server. I have found it is possible for the server to end up with multiple sink pointers from different clients, but when a method is called on each sink pointer, the same client ends up getting every method call!
In other words when each client has asked COM for a sink i'face pointer to giver to the server, COM has got the pointer from the same client instance and has not got the instance belonging to each separate client. The apparantly unique sink pointers all point to one instance of the sink in one client only.
I can understand why this might be so, given that our clients are exe servers not in-proc dll's. CreateInstance just makes COM go out and find the nearest process that can provide an implementation of the requested interface; the "default" behaviour is not to avoid getting multiple i'face pointers from the same class factory.
There appears to be a number of ways to solve this problem. The simplest way seems to be to use the IDL keyword "source" in the IDL declaration of the callback interface. The **server** IDL declares the callback interface, marked with [source]. The client imports the server type library and implements the sink interface (via ATL or whatever). Then it asks COM for a pointer to its i'face implementation and, in this case, the pointers really are to each client's own instance of the i'face.
All the COM books I've read mention [source] but its not until you start playing with multiple clients that you see why it is really necessary.
Originally posted by: robin
Please see the following codes:
void __cdecl ProcessingThreadFn( void * lParam)
{
CCoMathServer03 *pMod = (CCoMathServer03*)lParam;
//do long operation here...Something here
::EnterCriticalSection(&mLock) ;
Sleep(4000);//simulate a long process...
short result = pMod->m_DataFromClient*10;
::LeaveCriticalSection(&mLock) ;
pMod->OnTaskFinished(result);
}
Condition:
Before threadA run, m_DataFromClient was set to 10.
Before threadB run, m_DataFromClient was set to 20.
If threadA suspends at CCoMathServer03 *pMod = (CCoMathServer03*)lParam, threadB also runs to here and then suspends. Then, threadA resume, How about result:
short short = pMod->m_DataFromClient. 10 or 20??????
Originally posted by: Ashish
Robin Please build debug config. of the project or else remove _ATL_MIN_CRT from project settings of Release_mindependency configuration
Thanks
ashish
Originally posted by: Ashish
Robin Please build debug config. of the project or else remove _ATL_MIN_CRT from project settings of Relase_mindependencies configuration
Thanks
ashish
Originally posted by: robin
Linking...
Creating library ReleaseUMinDependency/Server03.lib and object ReleaseUMinDependency/Server03.exp
LIBCMT.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
ReleaseUMinDependency/Server03.dll : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
Server03.dll - 2 error(s), 0 warning(s)
ReplyOriginally posted by: John
I think you need to go in to more detail for the beginner.
There are some steps missing - Call back interface creation