Follow recommended Disposable pattern.

This commit is contained in:
the_fiddler 2008-07-10 15:20:48 +00:00
parent 39dbdb997c
commit 1682b54efb

View file

@ -1372,14 +1372,20 @@ namespace OpenTK
/// <summary> /// <summary>
/// Disposes of the GameWindow, releasing all resources consumed by it. /// Disposes of the GameWindow, releasing all resources consumed by it.
/// </summary> /// </summary>
public virtual void Dispose() public void Dispose()
{ {
if (disposed) throw new ObjectDisposedException("GameWindow"); try
Dispose(true); {
Dispose(true);
}
finally
{
DisposeInternal(true);
}
GC.SuppressFinalize(this); GC.SuppressFinalize(this);
} }
private void Dispose(bool manual) private void DisposeInternal(bool manual)
{ {
if (!disposed) if (!disposed)
{ {
@ -1401,10 +1407,19 @@ namespace OpenTK
} }
} }
/// <summary>Finalizes unmanaged resources consumed by the GameWindow.</summary> /// <summary>
/// Override to add custom cleanup logic.
/// </summary>
/// <param name="manual">True, if this method was called by the application; false if this was called by the finalizer thread.</param>
protected virtual void Dispose(bool manual)
{
}
///// <summary>Finalizes unmanaged resources consumed by the GameWindow.</summary>
//~GameWindow() //~GameWindow()
//{ //{
// Dispose(false); // Dispose(false);
// DisposeInternal(false);
//} //}
#endregion #endregion