Use optimized Dispose pattern with suppressed finalizer on Dispose()
This commit is contained in:
parent
0d821fdaa6
commit
4d02a77d74
1 changed files with 14 additions and 2 deletions
|
|
@ -113,7 +113,7 @@ namespace MatterHackers.GCodeVisualizer
|
|||
GL.DisableClientState(ArrayCap.ColorArray);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
// release unmanaged resources
|
||||
if (!disposed)
|
||||
|
|
@ -126,11 +126,23 @@ namespace MatterHackers.GCodeVisualizer
|
|||
|
||||
disposed = true;
|
||||
}
|
||||
|
||||
if (disposing)
|
||||
{
|
||||
// release other Managed objects
|
||||
// if (resource!= null) resource.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
~GCodeVertexBuffer()
|
||||
{
|
||||
Dispose();
|
||||
Dispose(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue