diff --git a/docs/advanced/performance.md b/docs/advanced/performance.md index afa23240537..4c38e37b288 100644 --- a/docs/advanced/performance.md +++ b/docs/advanced/performance.md @@ -37,9 +37,10 @@ await resiliencePipeline.ExecuteAsync( cancellationToken); // This approach uses a static lambda, avoiding allocations. -// The "userId" is stored as state, and the lambda consumes it. +// The "userId" is passed to the execution via the state argument, and the lambda consumes it as the first +// parameter passed to the GetMemberAsync() method. In this case, userIdAsState and userId are the same value. await resiliencePipeline.ExecuteAsync( - static (state, cancellationToken) => GetMemberAsync(state, cancellationToken), + static (userIdAsState, cancellationToken) => GetMemberAsync(userIdAsState, cancellationToken), userId, cancellationToken); ``` diff --git a/src/Snippets/Docs/Performance.cs b/src/Snippets/Docs/Performance.cs index fb4bfc8cb9b..0af9d0881b9 100644 --- a/src/Snippets/Docs/Performance.cs +++ b/src/Snippets/Docs/Performance.cs @@ -22,9 +22,10 @@ await resiliencePipeline.ExecuteAsync( cancellationToken); // This approach uses a static lambda, avoiding allocations. - // The "userId" is stored as state, and the lambda consumes it. + // The "userId" is passed to the execution via the state argument, and the lambda consumes it as the first + // parameter passed to the GetMemberAsync() method. In this case, userIdAsState and userId are the same value. await resiliencePipeline.ExecuteAsync( - static (state, cancellationToken) => GetMemberAsync(state, cancellationToken), + static (userIdAsState, cancellationToken) => GetMemberAsync(userIdAsState, cancellationToken), userId, cancellationToken);