Dispose() public method

public Dispose ( ) : void
return void
        protected override void Dispose(bool disposing)
        {
            if (_view != null)
            {
                _view.Dispose();
                _view = null;
            }

            base.Dispose(disposing);
        }
Esempio n. 2
0
        protected override void Dispose(bool disposing)
        {
            if (!IsDisposed)
            {
                if (toolkit != null)
                {
                    toolkit.Dispose();
                    toolkit = null;
                }

                if (_view != null)
                {
                    _view.Dispose();
                    _view = null;
                }
            }

            base.Dispose(disposing);
        }
        public override void RunLoop()
        {
            ResetWindowBounds();
            while (true)
            {
                _view.ProcessEvents();

                // Stop the main loop iff Game.Exit() has been called.
                // This can happen under the following circumstances:
                // 1. Game.Exit() is called programmatically.
                // 2. The GameWindow is closed through the 'X' (close) button
                // 3. The GameWindow is closed through Alt-F4 or Cmd-Q
                // Note: once Game.Exit() is called, we must stop raising
                // Update or Draw events as the GameWindow and/or OpenGL context
                // may no longer be available.
                // Note 2: Game.Exit() can be called asynchronously from
                // _view.ProcessEvents() (cases #2 and #3 above), so the
                // isExiting check must be placed *after* _view.ProcessEvents()
                // Note 3: We need to continue processing view events until
                // everything gets disposed of, otherwise it will close the window
                // and make the window handle invalid
                if (isExiting == 0)
                {
                    Game.Tick();
                }
                else if (windowDelay == 2)
                {
                    windowDelay--;
                    Game.ExitEverything();
                }
                else if (windowDelay > 0)
                {
                    windowDelay--;
                }
                else
                {
                    _view.Dispose();
                    break;
                }
            }
        }