Exemplo n.º 1
0
        /// <summary>
        /// 実行。
        /// </summary>
        /// <param name="initialState">初期状態。</param>
        /// <param name="terminalState">終了状態。</param>
        /// <param name="initialOption">初期状態に遷移する際に渡すオプション。</param>
        /// <returns>実行完了待ちTask。</returns>
        public async Task RunAsync(CancellationToken ct, TState initialState, TState terminalState, TOption initialOption = default(TOption))
        {
            var arg = Transition.Result(initialState, initialOption);

            while (!arg.NextState.Equals(terminalState))
            {
                TransitionFunc f;
                if (!_table.TryGetValue(arg.NextState, out f))
                {
                    break;
                }

                CurrentState = arg.NextState;

                var t = f(arg.Option, ct);
                await Task.WhenAny(t, ct.AwaitCancel());

                if (ct.IsCancellationRequested)
                {
                    break;
                }

                arg = await t;
            }
        }
Exemplo n.º 2
0
        public override async Task RunAsync(int?initialStateId, CancellationToken ct)
        {
            await NavigateAsync <MyPage>(null);

            await ct.AwaitCancel();
        }