Click or drag to resize

HGlobal Class

Wrapper for a global memory handle. The memory will be allocated using AllocHGlobal(Int32); the memory will be freed when the object is disposed.
Inheritance Hierarchy
SystemObject
  TomsToolbox.DesktopHGlobal

Namespace:  TomsToolbox.Desktop
Assembly:  TomsToolbox.Desktop (in TomsToolbox.Desktop.dll) Version: 1.0.68.0
Syntax
public sealed class HGlobal : IDisposable

The HGlobal type exposes the following members.

Constructors
  NameDescription
Public methodHGlobal
Initializes a new instance of the HGlobal class.
Top
Properties
  NameDescription
Public propertyPtr
Gets the pointer to the allocated memory block.
Public propertySize
Gets the size of the allocated memory block.
Top
Methods
  NameDescription
Public methodDispose
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Protected methodFinalize
Finalizes an instance of the HGlobal class.
(Overrides ObjectFinalize.)
Public methodStatic memberToIntPtr
Performs a conversion from HGlobal to IntPtr.
Top
Operators
Extension Methods
  NameDescription
Public Extension MethodCode exampleReportNotDisposedObject
Handle reporting of a not disposed object.

Using this pattern is a good practice to avoid code where disposable objects get never disposed.

Calling this method will raise the NotDisposedObject event if any event handler is attached; otherwise it will throw an InvalidOperationException if a debugger is attached. If the application does not run in a debugger and no event handler is attached, calling this method does nothing.

(Defined by Disposable.)
Public Extension MethodSafeCastT
Performs a cast from object to T, avoiding possible null violations if T is a value type.

[CanBeNull]

(Defined by ObjectExtensions.)
Top
See Also