Skip to main content
The C# adapter uses P/Invoke (Platform Invocation Services) to call the Zinc C ABI. It provides a safe Span<byte> wrapper over the shared memory mapping.

Installation

Requires .NET 6 or later.

SharedRegion

Create

Creates a new region. Throws InvalidOperationException on failure.

Open

Opens an existing region.

Bytes

Returns a Span<byte> backed by the shared memory mapping. No copying occurs.

Notify

Wait

Returns true on notification, false on timeout.

Dispose

Complete example

P/Invoke details

The native function declarations:
The Bytes() method creates a Span<byte> from the native pointer and capacity using new Span<byte>((void*)ptr, (int)capacity). This is an unsafe context but the adapter encapsulates it. The span is valid only while the SharedRegion handle is not disposed. The zinc_core library must be on the system’s library search path, or placed in the same directory as the application executable.