From 1682b54efbc4073e3b23c6f724f8cadccb1cf975 Mon Sep 17 00:00:00 2001 From: the_fiddler Date: Thu, 10 Jul 2008 15:20:48 +0000 Subject: [PATCH] Follow recommended Disposable pattern. --- Source/OpenTK/GameWindow.cs | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/Source/OpenTK/GameWindow.cs b/Source/OpenTK/GameWindow.cs index 463c0b57..e1901870 100644 --- a/Source/OpenTK/GameWindow.cs +++ b/Source/OpenTK/GameWindow.cs @@ -1372,14 +1372,20 @@ namespace OpenTK /// /// Disposes of the GameWindow, releasing all resources consumed by it. /// - public virtual void Dispose() + public void Dispose() { - if (disposed) throw new ObjectDisposedException("GameWindow"); - Dispose(true); + try + { + Dispose(true); + } + finally + { + DisposeInternal(true); + } GC.SuppressFinalize(this); } - private void Dispose(bool manual) + private void DisposeInternal(bool manual) { if (!disposed) { @@ -1401,10 +1407,19 @@ namespace OpenTK } } - /// Finalizes unmanaged resources consumed by the GameWindow. + /// + /// Override to add custom cleanup logic. + /// + /// True, if this method was called by the application; false if this was called by the finalizer thread. + protected virtual void Dispose(bool manual) + { + } + + ///// Finalizes unmanaged resources consumed by the GameWindow. //~GameWindow() //{ // Dispose(false); + // DisposeInternal(false); //} #endregion