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