Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / March 2005

Tip: Looking for answers? Try searching our database.

marshalling connection point callback

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
J - 08 Feb 2005 23:11 GMT
I really need to know how to marshal my connection point interface (visual
studio 2003 ATL singleton service) so that I can broadcast new events that
have been received to applications that have expressed interest via the
connection point. The broadcast needs to take place in a second thread so
that logging of events via the primary are not delayed by the broadcast. I've
been playing around with the threadCoMarshalInterThreadInterfaceInStream
function but must admit that I am struggling to make it work.
Roger Montgomery - 09 Mar 2005 20:40 GMT
Hi J,

You probably have figured out a way to do it.  But I will let you know what
I did.

Your design pattern matches mine almost exactly.  Atl Server receiving
messages on one thread, buffering them, publishing those messages to
subscribers via connection points on another thread.

Create a Window in your windowless server for each connection point. It
doesn't have to be visible of course.  It just serves to receive messages
posted from your receiving thread.  Save the hWnd in a common document.

When your receiving thread gets a message, push it into a stack, post a
message to the Window's hWnd, and go back to receiving.

The Window which lives in the other thread will wakeup, go to the common
document, pop off the message, and send it to the subscribers.  You should
associate the interface pointer with the hWnd so you can make your
callbacks.

Since the Window was created in the same apartment that established the
connection point, it will be able to make the callback correctly.

BTW, don't try to callback using safearrays to your connection point
subscribers.  Pass back simple data types or simple strings and parse them
on the client side if you need that capability.  Or pass back an XML string
and let your .Net subscribing client handle the decoding.

Hope that helps,

Roger

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.