Name
GCHandle
Synopsis
This class is used when you need to pass a managed object to
unmanaged code. To use this class, pass an instance of
a .NET-managed type to the Alloc()
method. The
single-argument form of Alloc()
creates the GCHandle
with GCHandleType.Normal
,
which ensures that the object will not be freed by the garbage
collector. (This means that some kind of user code must also call the Free()
method
in order to release the object.) Managed code can use the Target
property to access the underlying object.
Public Structure GCHandle ' Public Instance Properties Public ReadOnly Property IsAllocated As Boolean Public Property Target As Object ' Public Shared Methods Public Shared Function Alloc( ByVal value As Object) As GCHandle Public Shared Function Alloc(ByVal value As Object, ByVal type As GCHandleType) As GCHandle Public Shared explicit operator Sub GCHandle( ByVal value As IntPtr) Public Shared explicit operator Sub IntPtr( ByVal value As GCHandle) ' Public Instance Methods Public Function AddrOfPinnedObject() As IntPtr Public Sub Free() End Structure
Hierarchy
System.Object→System.ValueType→ GCHandle
Get VB.NET Core Classes in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.