Cleanup IDisposable support
[vlc.git] / bindings / cil / src / marshal.cs
index 9d37394..2135aca 100644 (file)
@@ -97,8 +97,20 @@ namespace VideoLAN.LibVLC
          */
         public void Dispose ()
         {
-            ex.Dispose ();
-            handle.Close ();
+            Dispose (true);
+            GC.SuppressFinalize (this);
+        }
+
+        protected virtual void Dispose (bool disposing)
+        {
+            if (disposing)
+            {
+                ex.Dispose ();
+                if (handle != null)
+                    handle.Close ();
+            }
+            ex = null;
+            handle = null;
         }
     };
 };