====== Dispose Template ======
===== No Native Resources =====
// TODO: Mark class as IDisposable.
#region IDisposable Members
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposing)
{
if (disposing)
{
// Free managed resources.
if (managedResource != null)
{
managedResource.Dispose();
managedResource = null;
}
}
}
#endregion IDisposable Members
===== Native Resources =====
// TODO: Mark class as IDisposable.
#region IDisposable Members
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
~Resource()
{
Dispose(false);
}
protected virtual void Dispose(bool disposing)
{
if (disposing)
{
// Free managed resources.
if (managedResource != null)
{
managedResource.Dispose();
managedResource = null;
}
}
// Free native resources.
if (nativeResource != IntPtr.Zero)
{
Marshal.FreeHGlobal(nativeResource);
nativeResource = IntPtr.Zero;
}
}
#endregion IDisposable Members
{{tag>code_snippet c_sharp dispose idispose}}