问题
http://msdn.microsoft.com/en-us/library/ee2k0a7d.aspx
Event handling is also supported for native C++ classes (C++ classes that do not implement COM objects), however, that support is deprecated and will be removed in a future release.
Anyone knows why? Couldn't find any explanation for this statement.
回答1:
It's totally non-standard kludge that probably has very little actual users. And I mean non-stndard kludge even in WinNT and Microsoft-private world.
COM has much richer repertoire for event-like mechanisms and also allow fully multi-threaded code these days
This one is lethal - that functionality is doing implicit locking (probably our grandpa's idea of "synchonized" before templates and widespread safe use of normal critical sections). That makes it more dangerous than COM's single apartment, ahem, thing :-) As in it can give you a deadlock out of nowhere (happened to Java's synchronized methods as well - nothing special :-)
Everyone and their dogs know how to use normal multi-threading and at least critical sections with smart pointers these days, so besides being dangerous, that thing is also irrelevant.
回答2:
I'd hazard a guess, and it is just that, that similar functionality can be achieved by a signal/slots type library in a more more portable/standard C++ (with templates) fashion rather than requiring compiler support by MS.
回答3:
I'd hazard a guess that they would want you to do it all the .Net way now.
回答4:
Have a look at Boost::Signals2
(This is the successor of Boost Signals, which is no longer maintained)
来源:https://stackoverflow.com/questions/2295639/why-is-event-handling-in-native-visual-c-deprecated