Esempio n. 1
0
        protected virtual void Dispose(bool isDisposing)
        {
            if (_isDisposed)
            {
                return;
            }

            if (isDisposing)
            {
                if (_isRunning?.WaitOne(1) == false)
                {
                    _isRunning?.Set();
                }
                _componentRenderer.Dispose();
                try
                {
                    if (_drawingThread.ThreadState == ThreadState.Running && !_drawingThread.Join(500))
                    {
                        _drawingThread.Abort();
                    }
                }
                catch (PlatformNotSupportedException)
                {
                    // ignore thread-abort errors on unsupported platforms
                }
                try
                {
                    if (_inputThread.ThreadState == ThreadState.Running && !_inputThread.Join(500))
                    {
                        _inputThread.Abort();
                    }
                }
                catch (PlatformNotSupportedException)
                {
                    // ignore thread-abort errors on unsupported platforms
                }
                _drawingThread = null;
                _inputThread   = null;
                _bufferingComplete.Dispose();
                _frameDrawnComplete.Dispose();
                // _isRunning?.Dispose();
            }
            _isDisposed = true;
        }