private void OnTriggerComplete(NativeActivityContext context, System.Activities.ActivityInstance completedInstance) { int num = this.currentRunningTriggers.Get(context); this.currentRunningTriggers.Set(context, --num); bool flag = this.isExiting.Get(context); if ((!context.IsCancellationRequested && (num == 0)) && flag) { this.ScheduleExit(context); } else if (completedInstance.State == ActivityInstanceState.Closed) { bool flag2; InternalTransition transition = null; this.triggerInternalTransitionMapping.TryGetValue(completedInstance.Activity, out transition); StateMachineEventManager eventManager = this.EventManager.Get(context); TriggerCompletedEvent completedEvent = new TriggerCompletedEvent { Bookmark = this.evaluateConditionBookmark.Get(context), TriggedId = transition.InternalTransitionIndex }; eventManager.RegisterCompletedEvent(completedEvent, out flag2); if (flag2) { ProcessNextTriggerCompletedEvent(context, eventManager); } } }
private static void ProcessNextTriggerCompletedEvent(NativeActivityContext context, StateMachineEventManager eventManager) { eventManager.CurrentBeingProcessedEvent = null; eventManager.OnTransition = false; TriggerCompletedEvent nextCompletedEvent = eventManager.GetNextCompletedEvent(); if (nextCompletedEvent != null) { context.GetExtension <StateMachineExtension>().ResumeBookmark(nextCompletedEvent.Bookmark); } }
public TriggerCompletedEvent GetNextCompletedEvent() { while (this.queue.Count > 0) { TriggerCompletedEvent event2 = this.queue.Dequeue(); if (this.activeBookmarks.Contains(event2.Bookmark)) { this.CurrentBeingProcessedEvent = event2; return(event2); } } return(null); }
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> /// Gets next completed events queue. /// </summary> /// <returns>Top TriggerCompletedEvent item in the queue.</returns> public TriggerCompletedEvent GetNextCompletedEvent() { while (this.queue.Any()) { 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> /// <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; this.queue.Enqueue(completedEvent); return; }