diff --git a/Framework/TaskOrchestrationContext.cs b/Framework/TaskOrchestrationContext.cs index 91a48dac1..6f4c852db 100644 --- a/Framework/TaskOrchestrationContext.cs +++ b/Framework/TaskOrchestrationContext.cs @@ -30,6 +30,7 @@ internal class TaskOrchestrationContext : OrchestrationContext readonly IDictionary orchestratorActionsMap; readonly TaskScheduler taskScheduler; OrchestrationCompleteOrchestratorAction continueAsNew; + bool executionTerminated; int idCounter; public TaskOrchestrationContext(OrchestrationInstance orchestrationInstance, TaskScheduler taskScheduler) @@ -340,12 +341,19 @@ public void HandleTimerFiredEvent(TimerFiredEvent timerFiredEvent) public void HandleExecutionTerminatedEvent(ExecutionTerminatedEvent terminatedEvent) { - CompleteOrchestration(terminatedEvent.Input, null, OrchestrationStatus.Terminated); + if (!executionTerminated) + { + executionTerminated = true; + CompleteOrchestration(terminatedEvent.Input, null, OrchestrationStatus.Terminated); + } } public void CompleteOrchestration(string result) { - CompleteOrchestration(result, null, OrchestrationStatus.Completed); + if (!executionTerminated) + { + CompleteOrchestration(result, null, OrchestrationStatus.Completed); + } } public void FailOrchestration(Exception failure)