You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Waiting on multiple activities with Task.WhenAll should work when passing an IEnumerable.
Actual Behavior
When capturing the Tasks from multiple activity invocations, passing the tasks to Task.WhenAll works fine if the tasks are passed as a list. If the tasks are passed as an IEnumerable<Task> then the workflow never completes.
Steps to Reproduce the Problem
I have a workflow project where the set of activities to call is determined based on the payload of an incoming request. In the processing it is possible for multiple activities to be executed in parallel:
// ...varactionTasks=step.Actions.Select(action =>context.CallActivityAsync<InvokeProcessorResult>(nameof(InvokeProcessorActivity),action)).ToList();// if ToList is omitted, the workflow never completesawaitTask.WhenAll(actionTasks);// ...
Release Note
RELEASE NOTE: Fix awaiting multiple activity tasks works with IEnumerable
The text was updated successfully, but these errors were encountered:
@stuartleeks Do you have a repro project that you can share? I threw together a project but do not see that behavior; the workflow completes as expected once all the activities complete, whether .ToList() is used or not.
In the original, activityTasks is a LINQ-based lazily-evaluated IEnumerable<Task>. It will first be evaluated by the Task.WhenAll() which causes the activities to be spawned and then awaited. Once that's done, it gets to the activityTasks.Select(t=>t.Result).ToArray(). This causes a second evaluation of the enumerable which spawns the activities again, but then tries to synchronously wait for each to finish (due to the use of Result), which is where I think the problem arises.
Task.WhenAll() returns the results of each awaited Task so that they can be used without reevaluating the original enumerable.
Expected Behavior
Waiting on multiple activities with
Task.WhenAll
should work when passing an IEnumerable.Actual Behavior
When capturing the
Task
s from multiple activity invocations, passing the tasks toTask.WhenAll
works fine if the tasks are passed as a list. If the tasks are passed as anIEnumerable<Task>
then the workflow never completes.Steps to Reproduce the Problem
I have a workflow project where the set of activities to call is determined based on the payload of an incoming request. In the processing it is possible for multiple activities to be executed in parallel:
Release Note
RELEASE NOTE: Fix awaiting multiple activity tasks works with IEnumerable
The text was updated successfully, but these errors were encountered: