コード例 #1
0
        /// <summary>
        /// The method that derived classes should override to implement disposing of managed and native resources.
        /// </summary>
        /// <param name="disposing">True if managed objects should be disposed.</param>
        /// <remarks>Native resources should always be released regardless of the value of the disposing parameter.</remarks>
        protected virtual void Dispose(bool disposing)
        {
            if (!disposed)
            {
                if (disposing)
                {
                    // Release managed objects
                    // ...
                }

                // Release native objects
                // ...

                // Do not trigger the event if called from the finalizer
                if (disposing)
                {
                    EventHelpers.Raise(this, Disposing, EventArgs.Empty);
                }

                // Remove from the global list of graphics resources
                if (graphicsDevice != null)
                {
                    graphicsDevice.RemoveResourceReference(_selfReference);
                }

                _selfReference = null;
                graphicsDevice = null;
                disposed       = true;
            }
        }
コード例 #2
0
ファイル: GraphicsResource.cs プロジェクト: syun002/FNA
        /// <summary>
        /// The method that derived classes should override to implement disposing of
        /// managed and native resources.
        /// </summary>
        /// <param name="disposing">True if managed objects should be disposed.</param>
        /// <remarks>
        /// Native resources should always be released regardless of the value of the
        /// disposing parameter.
        /// </remarks>
        protected virtual void Dispose(bool disposing)
        {
            if (!IsDisposed)
            {
                // Do not trigger the event if called from the finalizer
                if (disposing && Disposing != null)
                {
                    Disposing(this, EventArgs.Empty);
                }

                // Remove from the list of graphics resources
                if (graphicsDevice != null && selfReference != null)
                {
                    graphicsDevice.RemoveResourceReference(selfReference);
                    selfReference = null;
                }

                IsDisposed = true;
            }
        }