public void PInvokeAuto() { for (int i = 0; i < Loop; i++) { WavHeader wavHeader3 = _native.ReadWavHeader(); } }
public void PInvokeManual() { for (int i = 0; i < Loop; i++) { _native.Read(out IntPtr data, out int length); WavHeader wavheader1 = Marshal.PtrToStructure <WavHeader>(data); } }
public unsafe void SpanStructAndRef() { for (int i = 0; i < Loop; i++) { byte * ptr = _native.ReadUnsafe(); Span <WavHeader> spanWavHeader = new Span <WavHeader>(ptr, 1); ref WavHeader refWavHeader = ref MemoryMarshal.GetReference <WavHeader>(spanWavHeader); // From MemoryMarshal sources: // public static ref T GetReference<T>(Span<T> span) => ref span._pointer.Value; }