예제 #1
0
 public void PInvokeAuto()
 {
     for (int i = 0; i < Loop; i++)
     {
         WavHeader wavHeader3 = _native.ReadWavHeader();
     }
 }
예제 #2
0
 public void PInvokeManual()
 {
     for (int i = 0; i < Loop; i++)
     {
         _native.Read(out IntPtr data, out int length);
         WavHeader wavheader1 = Marshal.PtrToStructure <WavHeader>(data);
     }
 }
예제 #3
0
        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;
            }