为什么本机 Visual C 中的事件处理如此复杂?已弃用?
http://msdn.microsoft.com/en-us/library/ee2k0a7d。 ASPX
还支持事件处理 本机 C++ 类(C++ 类 不实现 COM 对象), 但是,该支持已被弃用 并将在未来被删除 发布。
有人知道为什么吗?找不到此声明的任何解释。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这完全是非标准的拼凑,可能没有什么实际意义
用户。我的意思是非标准的拼凑,即使在 WinNT 和 Microsoft 私有世界中也是如此。
COM 具有更丰富的类事件机制,并且还允许
如今,完全多线程代码
这个是致命的 - 该功能正在执行隐式锁定(可能是我们祖父的想法
模板之前的“同步”以及正常关键部分的广泛安全使用)。那
使它比 COM 的单一公寓更危险,咳咳,事情 :-) 因为它可能会突然给你带来死锁(Java 的同步方法也发生过这种情况 - 没什么特别的 :-)
每个人和他们的狗都知道如何现在使用普通的多线程和至少带有智能指针的关键部分,所以除了危险之外,那件事也无关紧要。
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.
我大胆猜测,只是这样,类似的功能可以通过信号/槽类型库以更便携/标准的 C++(带模板)方式实现,而不需要 MS 的编译器支持。
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.
我大胆猜测他们希望您现在就以 .Net 方式完成这一切。
I'd hazard a guess that they would want you to do it all the .Net way now.
看看 Boost::Signals2
(这是 Boost Signals 的后继者,不再维护)
Have a look at Boost::Signals2
(This is the successor of Boost Signals, which is no longer maintained)