Ejemplo n.º 1
0
        public void EnqueueTransition(Enum transition, object data = null)
        {
            if (Equals(transition, StateMachineBaseTransition.Cancel))
            {
                throw new NotSupportedException("use \"StateMachine.Cancel()\" instead of enqueueing a cancel transition");
            }

            lock (_commandEnqueueLock)
            {
                _commandQueue.Add(StateMachineCommand.Transition(transition, data));
            }
        }
Ejemplo n.º 2
0
        public void Cancel(string reason = "undefined")
        {
            Logger.LogError($"cancelling Statemaschine with reason: {reason}");
            _transitionCts.Cancel();

            lock (new[] { _commandEnqueueLock, _commandDequeueLock })
            {
                while (_commandQueue.Count > 0)
                {
                    _commandQueue.Take();
                }

                _commandQueue.Add(StateMachineCommand.Transition(StateMachineBaseTransition.Cancel));

                _transitionCts = new CancellationTokenSource();
            }
        }