예제 #1
0
        /// <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;
                    _hasStartedCreatingInitialContext = false;
                }

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

            _defaultBackButtonHandler = null;

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

            MoveToBeforeResumeLifecycleState();

            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();
        }