From 0a831ff65b92087867a67ddf610189930d68a9fb Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Fri, 17 Feb 2023 19:23:34 +0100 Subject: [PATCH] Fix DispatchWorkflow --- .../Activities/DispatchWorkflow.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/modules/Elsa.Workflows.Runtime/Activities/DispatchWorkflow.cs b/src/modules/Elsa.Workflows.Runtime/Activities/DispatchWorkflow.cs index 2bdae954c..af45e30a2 100644 --- a/src/modules/Elsa.Workflows.Runtime/Activities/DispatchWorkflow.cs +++ b/src/modules/Elsa.Workflows.Runtime/Activities/DispatchWorkflow.cs @@ -49,18 +49,21 @@ public class DispatchWorkflow : Activity, IBookmarksPersistedHandler protected override async ValueTask ExecuteAsync(ActivityExecutionContext context) { var waitForCompletion = WaitForCompletion.TryGet(context); + var identityGenerator = context.GetRequiredService(); + var instanceId = identityGenerator.GenerateId(); + context.TransientProperties["ChildInstanceId"] = instanceId; // If we need to wait for the child workflow to complete, create a bookmark. if (waitForCompletion) { - var identityGenerator = context.GetRequiredService(); - var instanceId = identityGenerator.GenerateId(); - context.TransientProperties["ChildInstanceId"] = instanceId; context.CreateBookmark(new DispatchWorkflowBookmark(instanceId)); } else - // Otherwise, we can complete. + { + // Otherwise, we can complete. + await BookmarksPersistedAsync(context); await context.CompleteActivityAsync(); + } } ///