Commit 8416c5ff authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Cleanup IDisposable support

parent e93cab16
...@@ -105,12 +105,6 @@ namespace VideoLAN.LibVLC ...@@ -105,12 +105,6 @@ namespace VideoLAN.LibVLC
private static extern void Init (NativeException e); private static extern void Init (NativeException e);
[DllImport ("libvlc.dll", EntryPoint="libvlc_exception_clear")] [DllImport ("libvlc.dll", EntryPoint="libvlc_exception_clear")]
private static extern void Clear (NativeException e); private static extern void Clear (NativeException e);
/*[DllImport ("libvlc.dll",
EntryPoint="libvlc_exception_raised")]
private static extern int Raised (NativeException e);*/
[DllImport ("libvlc.dll",
EntryPoint="libvlc_exception_get_message")]
private static extern IntPtr GetMessage (NativeException e);
public NativeException () public NativeException ()
{ {
...@@ -142,6 +136,17 @@ namespace VideoLAN.LibVLC ...@@ -142,6 +136,17 @@ namespace VideoLAN.LibVLC
/** IDisposable implementation. */ /** IDisposable implementation. */
public void Dispose () public void Dispose ()
{
Dispose (true);
GC.SuppressFinalize (this);
}
~NativeException ()
{
Dispose (false);
}
private void Dispose (bool disposing)
{ {
Clear (this); Clear (this);
} }
......
...@@ -97,8 +97,20 @@ namespace VideoLAN.LibVLC ...@@ -97,8 +97,20 @@ namespace VideoLAN.LibVLC
*/ */
public void Dispose () public void Dispose ()
{ {
ex.Dispose (); Dispose (true);
handle.Close (); GC.SuppressFinalize (this);
}
protected virtual void Dispose (bool disposing)
{
if (disposing)
{
ex.Dispose ();
if (handle != null)
handle.Close ();
}
ex = null;
handle = null;
} }
}; };
}; };
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