/// <summary>
        /// Gets next completed events queue.
        /// </summary>
        /// <returns>Top TriggerCompletedEvent item in the queue.</returns>
        public TriggerCompletedEvent GetNextCompletedEvent()
        {
            while (_queue.Any())
            {
                TriggerCompletedEvent completedEvent = _queue.Dequeue();
                if (_activeBookmarks.Contains(completedEvent.Bookmark))
                {
                    this.CurrentBeingProcessedEvent = completedEvent;
                    return(completedEvent);
                }
            }

            return(null);
        }
Example #2
0
        private static void ProcessNextTriggerCompletedEvent(NativeActivityContext context, StateMachineEventManager eventManager)
        {
            eventManager.CurrentBeingProcessedEvent = null;
            eventManager.OnTransition = false;

            TriggerCompletedEvent completedEvent = eventManager.GetNextCompletedEvent();

            if (completedEvent != null)
            {
                StateMachineExtension extension = context.GetExtension <StateMachineExtension>();
                Fx.Assert(extension != null, "Failed to obtain a StateMachineExtension.");
                extension.ResumeBookmark(completedEvent.Bookmark);
            }
        }
 /// <summary>
 /// Register a completed event and returns whether the event could be processed immediately.
 /// </summary>
 /// <param name="completedEvent">TriggerCompletedEvent reference.</param>
 /// <param name="canBeProcessedImmediately">True if the Condition can be evaluated.</param>
 public void RegisterCompletedEvent(TriggerCompletedEvent completedEvent, out bool canBeProcessedImmediately)
 {
     canBeProcessedImmediately = this.CanProcessEventImmediately;
     _queue.Enqueue(completedEvent);
     return;
 }