Click or drag to resize
AB4D logo

CompositionRenderingHelper Class

CompositionRenderingHelper class helps work with CompositionTarget.Rendering event with allowing subscribed objects to be collected by Garbage Collection and therefore preventing infinite rendering subscription in case when the Rendering is not unsubscribed.
Inheritance Hierarchy
SystemObject
  Ab3d.UtilitiesCompositionRenderingHelper

Namespace:  Ab3d.Utilities
Assembly:  Ab3d.PowerToys (in Ab3d.PowerToys.dll) Version: 10.0.8000.1045
Syntax
C#
public class CompositionRenderingHelper

The CompositionRenderingHelper type exposes the following members.

Methods
  NameDescription
Public methodIsSubscribed
Returns true if the specified subscriber is already subscribed to this CompositionRenderingHelper.
Public methodSubscribe
Subscribe the specified subscriber to be called on each CompositionTarget.Rendering event. The method prevents multiple subscription of the same object.
Public methodUnsubscribe
Unsubscribe the specified subscriber from being called on each CompositionTarget.Rendering event.
Top
Fields
  NameDescription
Public fieldStatic memberInstance
Static instance of CompositionRenderingHelper
Public fieldPreventMultipleRenderingCallsOnSameFrame
Gets or sets a boolean that specifies if duplicate Rendering calls on the same frame are prevented. Default valus is true.
Top
Remarks

CompositionRenderingHelper class helps work with CompositionTarget.Rendering event with allowing subscribed objects to be collected by Garbage Collection and therefore preventing infinite rendering subscription in case when the Rendering is not unsubscribed.

To use the CompositionRenderingHelper, the class that wants to subscribe to CompositionTarget.Rendering need to implement ICompositionRenderingSubscriber interface.

Then the class can be subscribed to the CompositionTarget.Rendering event with calling the Subscribe(ICompositionRenderingSubscriber) method. To unsubscribe call the Unsubscribe(ICompositionRenderingSubscriber) method.

CompositionRenderingHelper stores the subscribed classes as WeakReferences. This way the class is automatically unsubscribed when it is recylced by Garbage collector.

When there is no subscribed assigned the CompositionRenderingHelper is not subscribed to the CompositionTarget.Rendering event.

NOTE
It's possible for Rendering to call back twice in the same frame. With setting PreventMultipleRenderingCallsOnSameFrame to true (by default), such duplicate calls are prevented.

See Also