diff --git a/src/modules/Elsa.Workflows.Core/Activities/Flowchart/Activities/FlowFork.cs b/src/modules/Elsa.Workflows.Core/Activities/Flowchart/Activities/FlowFork.cs
index aa575b6fc..b3a8b9486 100644
--- a/src/modules/Elsa.Workflows.Core/Activities/Flowchart/Activities/FlowFork.cs
+++ b/src/modules/Elsa.Workflows.Core/Activities/Flowchart/Activities/FlowFork.cs
@@ -31,7 +31,7 @@ public class FlowFork : Activity
///
protected override async ValueTask ExecuteAsync(ActivityExecutionContext context)
{
- var outcomes = Branches.GetOrDefault(context)?.ToArray() ?? new[] { "Done" };
+ var outcomes = Branches.GetOrDefault(context)?.ToArray() ?? ["Done"];
await context.ScheduleOutcomesAsync(outcomes);
}
diff --git a/src/modules/Elsa.Workflows.Core/Activities/Flowchart/Activities/Flowchart.cs b/src/modules/Elsa.Workflows.Core/Activities/Flowchart/Activities/Flowchart.cs
index cc0def319..7dd514ede 100644
--- a/src/modules/Elsa.Workflows.Core/Activities/Flowchart/Activities/Flowchart.cs
+++ b/src/modules/Elsa.Workflows.Core/Activities/Flowchart/Activities/Flowchart.cs
@@ -298,11 +298,16 @@ public class Flowchart : Container
{
ExistingActivityExecutionContext = activityExecutionContext,
CompletionCallback = OnChildCompletedAsync,
+ Input = signal.Input
});
}
else
{
- await flowchartContext.ScheduleActivityAsync(activity, OnChildCompletedAsync);
+ await flowchartContext.ScheduleActivityAsync(activity, new ScheduleWorkOptions
+ {
+ CompletionCallback = OnChildCompletedAsync,
+ Input = signal.Input
+ });
}
}
}
\ No newline at end of file
diff --git a/src/modules/Elsa.Workflows.Core/Signals/ScheduleChildActivity.cs b/src/modules/Elsa.Workflows.Core/Signals/ScheduleChildActivity.cs
index e08714b4f..3b508defa 100644
--- a/src/modules/Elsa.Workflows.Core/Signals/ScheduleChildActivity.cs
+++ b/src/modules/Elsa.Workflows.Core/Signals/ScheduleChildActivity.cs
@@ -1,4 +1,5 @@
using Elsa.Workflows.Contracts;
+using Elsa.Workflows.Options;
namespace Elsa.Workflows.Signals;
@@ -11,23 +12,32 @@ public class ScheduleChildActivity
/// Signaled when the scheduling of a child activity was requested.
///
/// The child activity to schedule.
- public ScheduleChildActivity(IActivity activity)
+ /// Input to pass to the child activity.
+ public ScheduleChildActivity(IActivity activity, IDictionary? input = default)
{
Activity = activity;
+ Input = input;
}
///
/// Signaled when the scheduling of a child activity was requested.
///
/// The child activity execution context to schedule.
- public ScheduleChildActivity(ActivityExecutionContext? activityExecutionContext)
+ /// The scheduling options.
+ public ScheduleChildActivity(ActivityExecutionContext? activityExecutionContext, IDictionary? input = default)
{
ActivityExecutionContext = activityExecutionContext;
+ Input = input;
}
/// The child activity to schedule.
public IActivity? Activity { get; init; }
+ ///
+ /// Input to pass to the child activity.
+ ///
+ public IDictionary? Input { get; set;}
+
///
/// The child activity execution context to schedule.
///
diff --git a/src/samples/aspnet/Elsa.Samples.AspNet.BatchProcessing/Activities/FetchProducts.cs b/src/samples/aspnet/Elsa.Samples.AspNet.BatchProcessing/Activities/FetchProducts.cs
index f54dcb9fb..ead9d45a1 100644
--- a/src/samples/aspnet/Elsa.Samples.AspNet.BatchProcessing/Activities/FetchProducts.cs
+++ b/src/samples/aspnet/Elsa.Samples.AspNet.BatchProcessing/Activities/FetchProducts.cs
@@ -5,6 +5,7 @@ using Elsa.Workflows;
using Elsa.Workflows.Attributes;
using Elsa.Workflows.Models;
using Elsa.Workflows.Options;
+using Elsa.Workflows.Signals;
namespace Elsa.Samples.AspNet.BatchProcessing.Activities;
@@ -33,24 +34,17 @@ public class FetchProducts : CodeActivity>
var currentBatch = context.ActivityInput.TryGetValue(CurrentBathKey, out var currentBatchValue) ? (int)currentBatchValue : 0;
var orders = GenerateProducts(count).Skip(currentBatch * batchSize).Take(batchSize).ToList();
+ Result.Set(context, orders);
+ await context.CompleteActivityAsync();
+
if (orders.Any())
{
currentBatch++;
context.SetProperty(CurrentBathKey, currentBatch);
- Result.Set(context, orders);
// Schedule the next batch.
- await context.ScheduleActivityAsync(this, new ScheduleWorkOptions
- {
- Input = new Dictionary
- {
- [CurrentBathKey] = currentBatch
- }
- });
+ await context.SendSignalAsync(new ScheduleChildActivity(this, new Dictionary { [CurrentBathKey] = currentBatch }));
}
-
- // Complete the activity.
- await context.CompleteActivityAsync();
}
private IEnumerable GenerateProducts(int count)