protected override void UpdateInstance(NativeActivityUpdateContext updateContext)
{
StateMachineEventManager eventManager = updateContext.GetValue(this.EventManager) as StateMachineEventManager;
Fx.Assert(eventManager != null, "eventManager is available in every internalActivity.");
if (eventManager.CurrentBeingProcessedEvent != null || eventManager.Queue.Any())
{
// Updated state is evaluating conditions or transitioning to another state,
// Then we need to update the index of the current evaluated trigger (in case the trigger is moved)
// and the condition index.
// if the state is transitioning already, then we should update destination state id.
bool isUpdateSuccessful = this.UpdateEventManager(updateContext, eventManager);
if (!isUpdateSuccessful)
{
updateContext.DisallowUpdate(SR.DUTriggerOrConditionChangedDuringTransitioning);
return;
}
if (updateContext.GetValue(this.isExiting) != true)
{
this.RescheduleNewlyAddedTriggers(updateContext);
}
}
else if (updateContext.GetValue(this.currentRunningTriggers) > 0)
{
Fx.Assert(updateContext.GetValue(this.isExiting) != true, "No triggers have completed, state should not be transitioning.");
// the state is not transitioning yet and is persisted at trigger.
this.RescheduleNewlyAddedTriggers(updateContext);
}
}