Skip to main content

UnmanagedBuffer Class

Namespace: GHIElectronics.TinyCLR.Native · Assembly: GHIElectronics.TinyCLR.Native

A fixed-address byte buffer suitable for DMA targets and native interop. The Bytes property exposes it as a regular byte[]. Dispose to release the underlying memory.

public class UnmanagedBuffer : IDisposable

Constructors

UnmanagedBuffer(int length)

public UnmanagedBuffer(int length) : this(length, UnmanagedBufferLocation.UnmanagedMemory)

Allocates a buffer of the given length in the unmanaged heap.

ParameterTypeDescription
lengthint

UnmanagedBuffer(int length, UnmanagedBufferLocation location)

public UnmanagedBuffer(int length, UnmanagedBufferLocation location)

Allocates a buffer of the given length from the specified heap.

ParameterTypeDescription
lengthintBuffer size in bytes.
locationUnmanagedBufferLocationHeap to allocate from. Only UnmanagedBufferLocation.UnmanagedMemory is supported.

Properties

Bytes

public byte[] Bytes { get; }

Byte[] view of the unmanaged region. Same address every read.

Methods

Dispose()

public void Dispose()

Releases the unmanaged region.