Пример #1
0
        protected virtual void Dispose(bool disposing)
        {
            // Unlock the mouse cursor
            Cursor.Clip = new Rectangle();

            if (disposing)
            { // This block will only be executed on manual disposal, not by Garbage Collection
                Engine?.Dispose();
                Form?.Dispose();
                _debugConsole?.Dispose();

                // Stop tracking input
                KeyboardInputProvider?.Dispose();
                MouseInputProvider?.Dispose();
                TouchInputProvider?.Dispose();

                // Assume this is the only usage of SlimDX in the entire process (true for games, not for editors)
                if (ObjectTable.Objects.Count > 0)
                {
                    string leaks = ObjectTable.ReportLeaks();
                    Log.Error(leaks);
#if DEBUG
                    throw new InvalidOperationException(leaks);
#endif
                }
            }
            else
            { // This block will only be executed on Garbage Collection, not by manual disposal
                Log.Error("Forgot to call Dispose on " + this);
#if DEBUG
                throw new InvalidOperationException("Forgot to call Dispose on " + this);
#endif
            }
        }
Пример #2
0
        //--------------------//

        #region Dispose
        protected override void Dispose(bool disposing)
        {
            try
            {
                _renderTimer.Dispose();

                Engine?.Dispose();
                TouchInputProvider?.Dispose();
                MouseInputProvider?.Dispose();
                KeyboardInputProvider?.Dispose();
            }
            finally
            {
                base.Dispose(disposing);
            }
        }