Pls write with ex. thnx. Tina
Replyfine concept
ReplyAnyone who knows how to write Connection Point in Service(EXE) can tell me how to do via email(nimitz@tsinghua.org.cn). Thank you very much! And example is also welcome.
ReplyOriginally posted by: Vineet Kmar
This article is a good work to understand the connection point handling.The explanation ia very clear.I wanted this type of example,as it gives a chance to move furthur.
ReplyOriginally posted by: xialingxue
as the author show us in the sample,pAdd->Add() ought to be works asychronous call,but in fact ,the method work still sychronus. then I wonder if the call of pClientSink->ExecutionOver(a+b) is usefullessness.
The reason the call isn't asynchronous is because it calls Fire_ExecutionOver() from within it's body. This brings up a dialog box, a blocking operation, the Add() function cannot return until Fire_ExecutionOver() returns (until the dialog box has been closed). It is necessary therefore to decouple the Add() function from it's call. One method of doing this would be to place the parameters into a deque of events (with suitable locking objects attached if needed) and return immeditately. The CoClass implementing IAdd would have then to have it's own thread, reading the parameters from the same deque, performing the necessary actions (i.e. perform the Add()) and then calling the Fire_ExecutionOver() from with it's own thread. I have to say though, I don't know if the sample is setup to allow calling the connection point across threads, but that might merely be solved by entering the multi-threaded appatment prior to creaing the IAdd interface. Hope that helps (should you see my response!) Ian
ReplyOriginally posted by: Sway
In my opinion, this feature of COM should act like a working thread. However, while COM's Add is working, I tried to move the dialog window - it didn't respond unitil the Add method is returned. How come?
Reply
Originally posted by: Meghana Parwate
I downloaded the example and executed the client. I do not get any message box from ExectionOver method in the Sink. Any knowledge abt why this happens?
Hi,
I am newbie to ATL/COM. I really appreciate your work(particularly your technical article on COM Connection Points).
May I know how do I create a thread in the COM Server (my own) method and then fire the Client event from the (newly Created) Thread's function?
When I create a Thread using the below code, it reports an error saying "global functions do not have 'this' pointers".
hThread = CreateThread( NULL, // default security attributes
0, // use default stack size
ThreadFunction, // thread function
reinterpret_cast< void* >(this), // argument to thread function
0, // use default creation flags
&dwThreadId); // returns the thread identifier
if (hThread == NULL)
{
DWORD dw = GetLastError();
char szBuf[80];
sprintf(szBuf, "CreateThread Function Failed - GetLastError returned %u\n",dw);
MessageBox(NULL, szBuf, "Error", MB_OK);
return FUNCTIONFAILED;
}
else
MessageBox(NULL,"CreateThread SUCCESS.","Info",MB_OK);
Or say for example, in your article(COM Connection Points), how do I call the add(number1, number2)inside a Thread.
Any help would be greately appreciated.
Many thanks in advance,
Reply
Yes, I had a similar problem when using VB for the client part. It seems that events get lost while the VB window doesn't have the focus. This happened quite often. So I decided to have a mutex protected FIFO queue for results reading all pending msgs upon any event received as well as on timer events. After all: I still prefer a TCP/IP stream or a Named Pipe!
ReplyOriginally posted by: Lee T
Great example! It really helps a lot. Simple and elegant!
Lee
Originally posted by: MrCeri
Excellent tutorial, thanks! My only minor gripe would be that the client stuff isn't too easy to follow if you haven't used MFC before, I found I had to refer to the source files within the downloadable zip. As I say, that's only a very minor criticism though.
Thanks again!
Ceri
-----------------------
http://www.mrceri.co.uk
Originally posted by: Vitaly
You can find a good example of using connection points here: http://homepage.eircom.net/~codexpert/sink/
Regards,
Vitaly
P.S. Best XP-style tooltips, menus and hyperlinks can be found on http://www.tooltips.net