private void HandleLongData(IntPtr wParam1, IntPtr wParam2)
        {
            if (MidiEventLongDataReceived == null)
            {
                return;
            }
            byte[]? data = null;
            byte status;

            lock (_syncRoot)
            {
                MidiInputLongDataBuffer buffer = _longMessageBuffers[wParam1];
                // FIXME: this is a nasty workaround for https://github.com/atsushieno/managed-midi/issues/49
                // We have no idea when/how this message is sent (midi in proc is not well documented).
                if (buffer.Header.dwBytesRecorded == 0)
                {
                    return;
                }

                status = Marshal.ReadByte(buffer.Header.lpData);
                if (buffer.Header.dwBytesRecorded > 1)
                {
                    data = new byte[buffer.Header.dwBytesRecorded - 1];
                    Marshal.Copy(buffer.Header.lpData, data, 1, ((int)buffer.Header.dwBytesRecorded) - 1);
                }

                if (!IsClosed)
                {
                    buffer.Recycle();
                }
                else
                {
                    _longMessageBuffers.Remove(buffer.Ptr);
                    buffer.Dispose();
                }
            }

            MidiEventLongData e;

            if (data == null)
            {
                e = new MidiEventLongData(status, null, 0, 0, (long)wParam2);
            }
            else
            {
                e = new MidiEventLongData(status, data, 0, data.Length, (long)wParam2);
            }
            MidiEventLongDataReceived?.Invoke(this, new MidiEventLongDataReceivedEventArgs(e));
        }
 public MidiEventLongDataReceivedEventArgs(MidiEventLongData midiEvent)
 {
     MidiEvent = midiEvent;
 }