elsa-workflows / elsa-workflows/elsa-core
ParallelForEach: using variables
- Dominant language
- C#
- Stars
- 7.9k
- Forks
- 1.5k
- Avg merge
- 15h 22m
- Merged PRs (30d)
- 114
Description
## Description
When running steps in parallel, it is not possible to transfer data between activities of step.
If use variables, the data is overwritten for all steps.
## Steps to Reproduce
1. Create a parallel loop.
2. For each step, perform an operation that returns a result.
3. Put this result in a variable.
``` csharp
public class TestWorkflow : WorkflowBase
{
protected override void Build(IWorkflowBuilder builder)
{
Variable stepVariable = builder.WithVariable().WithWorkflowStorage();
var sendHttpRequest = new SendHttpRequest
{
Url = new Input(new Uri("https://www.google.com/search?q=111111111")),
ParsedContent = new Output(stepVariable)
};
var stepWriteLine = new WriteLine(stepVariable);
var parallel = new ParallelForEach
{
Items = new Input(new Expression("JavaScript", "[\"first\", \"second\"]")),
Body = new Flowchart
{
Activities =
{
sendHttpRequest,
stepWriteLine
},
Connections =
{
new Connection(sendHttpRequest, stepWriteLine)
}
}
};
var initWriteLine = new WriteLine("Line");
builder.Root = new Flowchart
{
Start = initWriteLine,
Activities =
{
initWriteLine,
parallel
},
Connections =
{
new Connection(initWriteLine, parallel)
}
};
}
}
```
Contributor guide
Assessment
This issue has not been assessed yet.