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);
} }
......
...@@ -96,9 +96,21 @@ namespace VideoLAN.LibVLC ...@@ -96,9 +96,21 @@ namespace VideoLAN.LibVLC
* IDisposable::Dispose. * IDisposable::Dispose.
*/ */
public void Dispose () public void Dispose ()
{
Dispose (true);
GC.SuppressFinalize (this);
}
protected virtual void Dispose (bool disposing)
{
if (disposing)
{ {
ex.Dispose (); ex.Dispose ();
if (handle != null)
handle.Close (); 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