Commit 9758d7eb authored by Martin Finkel's avatar Martin Finkel
Browse files

Fix #5: Keep delegate ref before passing to native code to prevent GC collection

parent c786e7d7
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Security;
......@@ -20,6 +21,7 @@ namespace LibVLCSharp.Shared
public IntPtr NativeReference;
readonly List<EventCallback> _callbacks = new List<EventCallback>();
protected EventManager(IntPtr ptr)
......@@ -31,12 +33,18 @@ namespace LibVLCSharp.Shared
protected void AttachEvent(EventType eventType, EventCallback eventCallback)
if(Internal.LibVLCEventAttach(NativeReference, eventType, eventCallback, IntPtr.Zero) != 0)
if (Internal.LibVLCEventAttach(NativeReference, eventType, eventCallback, IntPtr.Zero) != 0)
throw new VLCException($"Could not attach event {eventType}");
protected void DetachEvent(EventType eventType, EventCallback eventCallback)
Internal.LibVLCEventDetach(NativeReference, eventType, eventCallback, IntPtr.Zero);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment