Skip to content

Fan-in fan-out

ctx.WhenAll runs several activities concurrently and resumes the workflow once all of them have completed — and like every step, the fan-out is durable: a crash mid-flight resumes cleanly without re-running finished branches.

Use ctx.CallActivity to create the pending activities, then await them together. Up to three differently-typed activities come back as a tuple:

var (hello, goodbye) = await ctx.WhenAll(
ctx.CallActivity((HelloActivities a) => a.Hello(input.Name)),
ctx.CallActivity((HelloActivities a) => a.Goodbye(input.GoodbyeId)),
cancellationToken
);

When every branch has the same result type, pass a sequence and get an array back:

var results = await ctx.WhenAll(
customers.Select(c =>
ctx.CallActivity((EmailActivities a) => a.SendNewsletter(c.Email))
),
cancellationToken
);