Exemple #1
0
        public async Task Start()
        {
            if (ChangeState(MachineState.Running))
            {
                // Skip root state
                State?previous = Root;
                State?current  = await GetNext(Root);

                while (State != MachineState.Stopped && current != null)
                {
                    if (State == MachineState.Paused)
                    {
                        await Task.Delay(10);
                    }
                    else
                    {
                        StateTransition?.Invoke(previous.Id, current.Id);
                        previous = current;

                        await current.Activate(Blackboard);

                        current = await GetNext(current);
                    }
                }

                ChangeState(MachineState.Stopped);
            }
        }