Exemplo n.º 1
0
        protected override void Destroy()
        {
            base.Destroy();

            lock (this)
            {
                if (Window != null && Window.IsActivated) // force the window to be in an correct state during destroy (Deactivated events are sometimes dropped on windows)
                {
                    Window.OnPause();
                }

                var array = new IGameSystemBase[GameSystems.Count];
                GameSystems.CopyTo(array, 0);
                for (int i = 0; i < array.Length; i++)
                {
                    var disposable = array[i] as IDisposable;
                    if (disposable != null)
                    {
                        disposable.Dispose();
                    }
                }

                // Reset allocator
                if (GraphicsContext != null)
                {
                    GraphicsContext.CommandList.Dispose();
                    GraphicsContext.ResourceGroupAllocator.Dispose();
                    GraphicsContext = null;
                }

                var disposableGraphicsManager = graphicsDeviceManager as IDisposable;
                if (disposableGraphicsManager != null)
                {
                    disposableGraphicsManager.Dispose();
                }

                DisposeGraphicsDeviceEvents();

                if (gamePlatform != null)
                {
                    gamePlatform.Release();
                }
            }
        }
Exemplo n.º 2
0
        protected override void Destroy()
        {
            base.Destroy();

            lock (this)
            {
                if (Window != null && Window.IsActivated) // force the window to be in an correct state during destroy (Deactivated events are sometimes dropped on windows)
                    Window.OnPause();

                var array = new IGameSystemBase[GameSystems.Count];
                GameSystems.CopyTo(array, 0);
                for (int i = 0; i < array.Length; i++)
                {
                    var disposable = array[i] as IDisposable;
                    if (disposable != null)
                    {
                        disposable.Dispose();
                    }
                }

                var disposableGraphicsManager = graphicsDeviceManager as IDisposable;
                if (disposableGraphicsManager != null)
                {
                    disposableGraphicsManager.Dispose();
                }

                DisposeGraphicsDeviceEvents();

                if (gamePlatform != null)
                {
                    gamePlatform.Release();
                }
            }
        }