IXRDependencyObject::AddDestroyedEventHandler (Compact 2013)
3/28/2014
This method adds an event handler for the Destroyed event, which occurs after all of the references to this dependency object are released.
Syntax
virtual HRESULT STDMETHODCALLTYPE AddDestroyedEventHandler(
__in IXRDelegate<XREventArgs>* pDelegate
) = 0;
Parameters
- pDelegate
[in] Pointer to an IXRDelegate<ArgType, [SenderType]> object that represents the event handler method to attach to the Destroyed event.
Return Value
Returns an HRESULT that indicates success or failure.
Remarks
The Destroyed event occurs after you release the last reference to this dependency object, for example, by calling the SAFE_RELEASE macro. When the reference count for this object reaches 0 (zero), the XAML for Windows Embedded runtime releases the memory used by the object.
Event handler methods are invoked synchronously, but in no particular order.
After you call an event handler method for the Destroyed event, this dependency object is no longer valid. Weak references to this object will be calls to an invalid virtual function table. You can add programming logic to a Destroyed event handler method to test for weak references that you can then set to null.
The CreateDelegate function provides a quick way to create the IXRDelegate<ArgType, [SenderType]> object.
You can attach multiple delegates to the same event.
To remove a delegate from the Destroyed event, call IXRDependencyObject::RemoveDestroyedEventHandler.
.NET Framework Equivalent
None.
Requirements
Header |
XamlRuntime.h, |
sysgen |
SYSGEN_XAML_RUNTIME |