ObjectiveCMarshal.CreateReferenceTrackingHandle Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Request native reference tracking for the supplied object.
public:
static System::Runtime::InteropServices::GCHandle CreateReferenceTrackingHandle(System::Object ^ obj, [Runtime::InteropServices::Out] Span<IntPtr> % taggedMemory);
public static System.Runtime.InteropServices.GCHandle CreateReferenceTrackingHandle (object obj, out Span<IntPtr> taggedMemory);
static member CreateReferenceTrackingHandle : obj * Span -> System.Runtime.InteropServices.GCHandle
Public Shared Function CreateReferenceTrackingHandle (obj As Object, ByRef taggedMemory As Span(Of IntPtr)) As GCHandle
Parameters
- obj
- Object
The object to track.
Returns
Reference tracking GC handle.
Exceptions
The ObjectiveCMarshal API has not been initialized.
Remarks
The Initialize() must be called prior to calling this function.
The obj
must have a type in its hierarchy marked with
ObjectiveCTrackedTypeAttribute.
The "Is Referenced" callback passed to Initialize()
will be passed the taggedMemory
returned from this function.
The memory it points at is defined by the length in the Span<T> and
will be zeroed out. It will be available until obj
is collected by the GC.
The memory pointed to by taggedMemory
can be used for any purpose by the
caller of this function and usable during the "Is Referenced" callback.
Calling this function multiple times with the same obj
will
return a new handle each time but the same tagged memory will be returned. The
tagged memory is only guaranteed to be zero initialized on the first call.
The caller is responsible for freeing the returned GCHandle.