简体   繁体   English

强弱事件

[英]Strong and Weak events

My understanding of events is having a list pointing to the delegate handlers, and whenever a publish is triggered, the aggregator loops through the list to invoke the ref pointers to the handlers. 我对事件的理解是有一个指向委托处理程序的列表,每当触发发布时,聚合器就会遍历该列表以调用指向处理程序的ref指针。

I have also read about strong and weak events on many places but I don't exactly understand what they are. 我还读过许多地方的强弱事件,但我不完全了解它们是什么。 What are strong and weak events? 什么是强事件和弱事件? What are their differences and their usage? 它们的区别和用法是什么?

Basically weak events are "normal events" registered using "weak references"... mostly "weak events" are used when building/implementing a control to avoid potential memory leaks since "strong events" (ie strong references) have an impact on lifetime... 基本上,弱事件是使用“弱引用”注册的“正常事件” ...在构建/实现控件时避免使用大多数“弱事件”,以避免潜在的内存泄漏,因为“强事件”(即强引用)会对生命周期产生影响...

For a full explanation with sample source and references see MSDN . 有关示例源和参考的完整说明,请参见MSDN

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM