Edit

Share via


PinnedGCHandle<T> Struct

Definition

Represents a strongly typed GC handle to a managed object.

generic <typename T>
 where T : classpublic value class PinnedGCHandle : IDisposable, IEquatable<System::Runtime::InteropServices::PinnedGCHandle<T>>
public struct PinnedGCHandle<T> : IDisposable, IEquatable<System.Runtime.InteropServices.PinnedGCHandle<T>> where T : class
type PinnedGCHandle<'T (requires 'T : null)> = struct
    interface IDisposable
Public Structure PinnedGCHandle(Of T)
Implements IDisposable, IEquatable(Of PinnedGCHandle(Of T))

Type Parameters

T

The type of the object this PinnedGCHandle<T> tracks to.

Inheritance
PinnedGCHandle<T>
Implements

Remarks

The object is pinned at a fixed ___location in the GC heap and allows its address to be taken.

This type corresponds to Pinned.

This type is unsafe if used incorrectly. Incorrect usage like mismanagement of lifetime, providing invalid handle value or concurrent disposal can result in hard to diagnose crashes or data corruptions.

Constructors

PinnedGCHandle<T>(T)

Allocates a handle for the specified object.

Properties

IsAllocated

Gets a value that indicates whether this handle has been allocated or not.

Target

Gets or sets the object this handle represents.

Methods

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

Equals(Object)

Indicates whether this instance and a specified object are equal.

Equals(PinnedGCHandle<T>)

Indicates whether the current object is equal to another object of the same type.

FromIntPtr(IntPtr)

Returns a new PinnedGCHandle<T> object created from a handle to a managed object.

GetAddressOfObjectData()

Retrieves the address of object data in a PinnedGCHandle<T>.

GetHashCode()

Returns the hash code for the current instance.

ToIntPtr(PinnedGCHandle<T>)

Returns the internal integer representation of a PinnedGCHandle<T> object.

Applies to

See also