static void ProcessNextTriggerCompletedEvent(NativeActivityContext context, StateMachineEventManager eventManager) { eventManager.CurrentBeingProcessedEvent = null; eventManager.OnTransition = false; TriggerCompletedEvent completedEvent = eventManager.GetNextCompletedEvent(); if (completedEvent != null) { context.ResumeBookmark(completedEvent.Bookmark, null); } }
/// <summary> /// Get next completed events queue. /// </summary> public TriggerCompletedEvent GetNextCompletedEvent() { while (this.queue.Count > 0) { TriggerCompletedEvent completedEvent = this.queue.Dequeue(); if (this.activeBookmarks.Contains(completedEvent.Bookmark)) { this.CurrentBeingProcessedEvent = completedEvent; return(completedEvent); } } return(null); }
/// <summary> /// Register a completed event and returns whether the event could be processed immediately. /// </summary> public void RegisterCompletedEvent(TriggerCompletedEvent completedEvent, out bool canBeProcessedImmediately) { if (CanProcessEventImmediately) { this.CurrentBeingProcessedEvent = completedEvent; canBeProcessedImmediately = true; return; } else if (queue.Count < MaxQueueLength) { this.queue.Enqueue(completedEvent); canBeProcessedImmediately = false; return; } canBeProcessedImmediately = false; throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, SR.TooManyCompletedEvents, MaxQueueLength)); }