void OnTriggerComplete(NativeActivityContext context, ActivityInstance completedInstance)
{
int runningTriggers = this.currentRunningTriggers.Get(context);
this.currentRunningTriggers.Set(context, --runningTriggers);
bool isOnExit = this.isExiting.Get(context);
if (!context.IsCancellationRequested && runningTriggers == 0 && isOnExit)
{
this.ScheduleExit(context);
}
else if (completedInstance.State == ActivityInstanceState.Closed)
{
InternalTransition internalTransition = null;
this.triggerInternalTransitionMapping.TryGetValue(completedInstance.Activity, out internalTransition);
Fx.Assert(internalTransition != null, "internalTransition should be added into triggerInternalTransitionMapping in CacheMetadata.");
StateMachineEventManager eventManager = this.EventManager.Get(context);
bool canBeProcessedImmediately;
eventManager.RegisterCompletedEvent(
new TriggerCompletedEvent { Bookmark = this.evaluateConditionBookmark.Get(context), TriggedId = internalTransition.InternalTransitionIndex },
out canBeProcessedImmediately);
if (canBeProcessedImmediately)
{
ProcessNextTriggerCompletedEvent(context, eventManager);
}
}
}