/// <summary>
        /// Destroy the <see cref="ReactInstanceManager"/>.
        /// </summary>
        public async Task DisposeAsync()
        {
            DispatcherHelpers.AssertOnDispatcher();

            // TODO: memory pressure hooks
            if (_useDeveloperSupport)
            {
                _devSupportManager.IsEnabled = false;
            }

            _lifecycleStateMachine.OnDestroy();
            _lifecycleStateMachine.SetContext(null);

            var currentReactContext = _currentReactContext;

            if (currentReactContext != null)
            {
                await currentReactContext.DisposeAsync();

                _currentReactContext = null;
                _hasStartedCreatingInitialContext = false;
            }

            ReactChoreographer.Dispose();
        }
        /// <summary>
        /// Destroy the <see cref="ReactInstanceManager"/>.
        /// </summary>
        public async Task DisposeAsync()
        {
            DispatcherHelpers.AssertOnDispatcher();
            using (await _lock.LockAsync())
            {
                // TODO: memory pressure hooks
                if (_useDeveloperSupport)
                {
                    _devSupportManager.IsEnabled = false;
                }

                _lifecycleStateMachine.OnDestroy();
                _lifecycleStateMachine.SetContext(null);

                var currentReactContext = _currentReactContext;
                if (currentReactContext != null)
                {
                    await currentReactContext.DisposeAsync();

                    _currentReactContext = null;
                }

                ReactChoreographer.Dispose();
                DispatcherHelpers.Reset();
            }
        }
        /// <summary>
        /// Called when the application is suspended.
        /// </summary>
        public void OnSuspend()
        {
            DispatcherHelpers.AssertOnDispatcher();

            _defaultBackButtonHandler = null;
            _suspendCancellation?.Dispose();

            if (_useDeveloperSupport)
            {
                _devSupportManager.IsEnabled = false;
            }

            _lifecycleStateMachine.OnSuspend();

            ReactChoreographer.Dispose();
            DispatcherHelpers.Reset();
        }
        /// <summary>
        /// Destroy the <see cref="ReactInstanceManager"/>.
        /// </summary>
        public async Task DisposeAsync()
        {
            DispatcherHelpers.AssertOnDispatcher();

            // TODO: memory pressure hooks
            if (_useDeveloperSupport)
            {
                _devSupportManager.IsEnabled = false;
            }

            MoveToBeforeCreateLifecycleState();

            var currentReactContext = _currentReactContext;

            if (currentReactContext != null)
            {
                await currentReactContext.DisposeAsync().ConfigureAwait(false);

                _currentReactContext = null;
                _hasStartedCreatingInitialContext = false;
            }

            ReactChoreographer.Dispose();
        }