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++ / September 2007

Tip: Looking for answers? Try searching our database.

__event?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
PGP - 30 Aug 2007 17:46 GMT
Anybody here using __event? Could you please discuss any potential issues
with it other than portability?

Priyesh
Ben Voigt [C++ MVP] - 30 Aug 2007 20:07 GMT
> Anybody here using __event? Could you please discuss any potential issues
> with it other than portability?

Nope.  People using C++ in the managed world are now using C++/CLI (new in
VC++ 2005) which no longer supports the __event keyword, instead using
"context-sensitive" keywords that are only recognized at certain locations.
PGP - 31 Aug 2007 18:37 GMT
>> Anybody here using __event? Could you please discuss any potential issues
>> with it other than portability?
[quoted text clipped - 3 lines]
> "context-sensitive" keywords that are only recognized at certain
> locations.

I was wondering about the native C++ part of it. Would you rather look into
a third party library or would you consider using the __event, __hook
and __unhook? Overall, I did not find any good feedback on the __event
mechanism during my research, but I would defenitely want to use it
if it's here to stay. I have done some tests of my own and tried out
MSDN samples. It does exactly what I want it to do. Now I am
looking for some reassurance.

Priyesh
Ben Voigt [C++ MVP] - 31 Aug 2007 20:55 GMT
>>> Anybody here using __event? Could you please discuss any potential
>>> issues with it other than portability?
[quoted text clipped - 6 lines]
> I was wondering about the native C++ part of it. Would you rather look
> into

You were in the C++/CLI newsgroup... microsoft.public.vc.language is focused
on native features.

> a third party library or would you consider using the __event, __hook
> and __unhook? Overall, I did not find any good feedback on the __event
> mechanism during my research, but I would defenitely want to use it
> if it's here to stay. I have done some tests of my own and tried out
> MSDN samples. It does exactly what I want it to do. Now I am
> looking for some reassurance.

Are you looking for COM compatibility?  If you just want event handling in
within a C++ application, then pointer-to-member-function is 100% in the C++
standard and does what you want.  In the rare case you need to support
multiple subscribers, then a std::vector or std::list of
pointer-to-member-function will get you there, again 100% standard and
portable.  A template helper function can hide the details of iterating
through and calling all receivers.  That will get even better in C++0x with
template support for arbitrary argument lists (not sure what the correct
name of the feature is).

> Priyesh
Boris - 02 Sep 2007 12:39 GMT
> [...]Are you looking for COM compatibility?  If you just want event  
> handling in within a C++ application, then pointer-to-member-function is  
> 100% in the C++ standard and does what you want.  In the rare case you  
> need to support multiple subscribers, then a std::vector or std::list of  
> pointer-to-member-function will get you there, again 100% standard and  
> portable.

Or have a look at Boost.Signals (see  
http://www.boost.org/doc/html/signals.html) which is  
C++ standard-compatible library which should do what you want out of the  
box.

Boris
PGP - 05 Sep 2007 18:19 GMT
>> [...]Are you looking for COM compatibility?  If you just want event
>> handling in within a C++ application, then pointer-to-member-function is
[quoted text clipped - 8 lines]
>
> Boris

Boris,

Thanks for the suggestion. Boost looks excellent. I have contemplated on
using
Boost multiple times before and havent yet. Although starting to use Boost
now
will be a good idea as there are other excellent features like regex that i
could
take advantage of, it is too much of a change to introduce at this point to
otherwise
stable code so i am a little worried.
Priyesh
PGP - 05 Sep 2007 18:14 GMT
>>>> Anybody here using __event? Could you please discuss any potential
>>>> issues with it other than portability?
[quoted text clipped - 28 lines]
>
>> Priyesh

Ben,
COM is not in the picture. I am also not worried about porting this code
outside MS compilers. Calling multiple subscribers is a needed feature.
__hook supports calling multiple subscribers and it's thread safe. Apart
from potential portability issues, it seems to me that __hook is a perfect
fit.
If i roll my own as you suggest, i am still left with the task of
synchronizing
access from multiple threads.
Priyesh

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.