Example #1
0
        public override Task EnterFromAsync(LauncherBase p, State fromState, TimeSpan timeout)
        {
            if (!StateManager.TryEnter(p, fromState, this))
            {
                // Delegate StartAsync to current state, because it has already changed since
                // transition to this state was initiated.
                return(StateManager.CurrentState.StartAsync(p));
            }

            return(StartCoreAsync(p));
        }
        public void EnterFrom(LauncherBase p, State fromState)
        {
            if (!StateManager.TryEnter(p, fromState, this))
            {
                // Delegate Dispose to current state, because it has already changed since
                // transition to this state was initiated.
                StateManager.CurrentState.Dispose(p);
            }
            else if (fromState != StateManager.Exited)
            {
                Kill(p);

                p.ExitCompletionSource.TrySetException(new ObjectDisposedException(p.ToString()));
                p.TempUserDataDir?.Dispose();
            }
        }
        public void EnterFrom(LauncherBase p, State fromState)
        {
            while (!StateManager.TryEnter(p, fromState, this))
            {
                // Current state has changed since transition to this state was requested.
                // Therefore retry transition to this state from the current state. This ensures
                // that Leave() operation of current state is properly called.
                fromState = StateManager.CurrentState;
                if (fromState == this)
                {
                    return;
                }
            }

            p.ExitCompletionSource.TrySetResult(true);
            p.TempUserDataDir?.Dispose();
        }
        public override async Task EnterFromAsync(LauncherBase p, State fromState, TimeSpan timeout)
        {
            if (!StateManager.TryEnter(p, fromState, this))
            {
                // Delegate KillAsync to current state, because it has already changed since
                // transition to this state was initiated.
                await StateManager.CurrentState.KillAsync(p).ConfigureAwait(false);
            }

            try
            {
                if (!p.Process.HasExited)
                {
                    p.Process.Kill();
                }
            }
            catch (InvalidOperationException)
            {
                // Ignore
                return;
            }

            await WaitForExitAsync(p).ConfigureAwait(false);
        }
 public override Task EnterFromAsync(LauncherBase p, State fromState, TimeSpan timeout)
 => !StateManager.TryEnter(p, fromState, this) ? StateManager.CurrentState.ExitAsync(p, timeout) : ExitAsync(p, timeout);
 public override Task EnterFromAsync(LauncherBase p, State fromState, TimeSpan timeout)
 {
     StateManager.TryEnter(p, fromState, this);
     return(Task.CompletedTask);
 }