Open sandboxFocus

Class WeakEventAttribute

Aspect that, when applied to an event, prevents the target event from holding a strong reference to event handlers. Therefore, the aspect prevents the event to prevent clients to be garbage collected.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Model.dll
Syntax
[LinesOfCodeAvoided(6)]
[Serializer(typeof(WeakEventAttribute.Serializer))]
public sealed class WeakEventAttribute : EventInterceptionAspect, IEventLevelAspectBuildSemantics, IAspectBuildSemantics, IValidableAnnotation, IEventInterceptionAspect, IEventLevelAspect, IInstanceScopedAspect, IAspect
Remarks

Event clients do not need to keep a strong reference to the delegates passed to a weak event. The WeakEventAttribute implementation will keep delegate instances alive as long as the event source (i.e. whatever object the Target property points to) is alive, but no longer.

Constructors

Name Description
WeakEventAttribute()
WeakEventAttribute(PortableFormatterConstructorContext)

Methods

Name Description
~WeakEventAttribute()

Destructor.