GCHandle<T> Struct
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.
Represents a strongly typed GC handle to a managed object.
generic <typename T>
where T : classpublic value class GCHandle : IDisposable, IEquatable<System::Runtime::InteropServices::GCHandle<T>>
public struct GCHandle<T> : IDisposable, IEquatable<System.Runtime.InteropServices.GCHandle<T>> where T : class
type GCHandle<'T (requires 'T : null)> = struct
interface IDisposable
Public Structure GCHandle(Of T)
Implements IDisposable, IEquatable(Of GCHandle(Of T))
Type Parameters
- T
The type of the object this GCHandle<T> tracks to.
- Inheritance
- Implements
Remarks
A GC handle is used to work with object references in unmanaged code.
This type corresponds to Normal.
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
GCHandle<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(GCHandle<T>) |
Indicates whether the current object is equal to another object of the same type. |
Equals(Object) |
Indicates whether this instance and a specified object are equal. |
FromIntPtr(IntPtr) |
Returns a new GCHandle<T> object created from a handle to a managed object. |
GetHashCode() |
Returns the hash code for the current instance. |
ToIntPtr(GCHandle<T>) |
Returns the internal integer representation of a GCHandle<T> object. |