Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend snippet explanation #2373

Merged
merged 1 commit into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions docs/advanced/performance.md
Original file line number Diff line number Diff line change
Expand Up @@ -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);
```
Expand Down
5 changes: 3 additions & 2 deletions src/Snippets/Docs/Performance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down