ImageGlass.ImageBox.Dispose C# (CSharp) Method

Dispose() protected method

Clean up any resources being used.
protected Dispose ( bool disposing ) : void
disposing bool true if managed resources should be disposed; otherwise, false.
return void
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (IsAnimating)
                {
                    // ReSharper disable once HeapView.DelegateAllocation
                    ImageAnimator.StopAnimate(Image, OnFrameChangedHandler);
                }

                if (_hScrollBar != null)
                {
                    Controls.Remove(_hScrollBar);
                    // ReSharper disable once HeapView.DelegateAllocation
                    _hScrollBar.Scroll -= ScrollBarScrollHandler;
                    _hScrollBar.Dispose();
                }

                if (_vScrollBar != null)
                {
                    Controls.Remove(_vScrollBar);
                    // ReSharper disable once HeapView.DelegateAllocation
                    _vScrollBar.Scroll -= ScrollBarScrollHandler;
                    _vScrollBar.Dispose();
                }

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

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

            base.Dispose(disposing);
        }
ImageBox