/// <summary>
        /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
        /// </summary>
        public void Dispose()
        {
            if (_disposed)
            {
                return;
            }

            _disposed = true;
            if (CallbackFunction != null)
            {
                CallbackFunction.Dispose();
                CallbackFunction = null;
            }

            if (_disposeHandler != null)
            {
                _disposeHandler(this);
                _disposeHandler = null;
            }
        }