From fe65476bf2d7d2119ddaf6e8ce185adbed550d62 Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Sat, 15 Mar 2025 20:03:22 +0100 Subject: [PATCH] Add WorkflowExecutionState to manage execution context state Introduce `WorkflowExecutionState` to encapsulate execution state changes for workflows. This ensures proper handling of execution flags during the lifetime of the state object and resets them upon disposal. --- .../Models/WorkflowExecutionState.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/modules/Elsa.Workflows.Core/Models/WorkflowExecutionState.cs diff --git a/src/modules/Elsa.Workflows.Core/Models/WorkflowExecutionState.cs b/src/modules/Elsa.Workflows.Core/Models/WorkflowExecutionState.cs new file mode 100644 index 000000000..1d8e48dad --- /dev/null +++ b/src/modules/Elsa.Workflows.Core/Models/WorkflowExecutionState.cs @@ -0,0 +1,17 @@ +namespace Elsa.Workflows; + +internal class WorkflowExecutionState : IDisposable +{ + private readonly ActivityExecutionContext _activityExecutionContext; + + public WorkflowExecutionState(ActivityExecutionContext activityExecutionContext) + { + _activityExecutionContext = activityExecutionContext; + _activityExecutionContext.IsExecuting = activityExecutionContext.WorkflowExecutionContext.IsExecuting = true; + } + + public void Dispose() + { + _activityExecutionContext.IsExecuting = _activityExecutionContext.WorkflowExecutionContext.IsExecuting = false; + } +} \ No newline at end of file