Open
Conversation
Contributes to dotnet#17714 Port the first two articles for wrapping async methods in synchronous methods, and wrapping synchronous methods in asynchronous methods.
Do a full review and edit.
Contributor
There was a problem hiding this comment.
Pull request overview
Adds two new conceptual docs under Asynchronous programming patterns that explain why library authors should generally avoid sync-over-async and async-over-sync wrappers, plus accompanying C# and Visual Basic snippets, and wires the new articles into the Advanced .NET programming TOC.
Changes:
- Add new articles: Asynchronous wrappers for synchronous methods and Synchronous wrappers for asynchronous methods.
- Add runnable C# and VB snippet projects referenced by the new articles.
- Add both articles to
docs/navigate/advanced-programming/toc.ymlunder TAP.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| docs/standard/asynchronous-programming-patterns/synchronous-wrappers-for-asynchronous-methods.md | New conceptual article describing sync-over-async risks and mitigations. |
| docs/standard/asynchronous-programming-patterns/async-wrappers-for-synchronous-methods.md | New conceptual article describing why async-over-sync wrappers (Task.Run) are usually inappropriate for libraries. |
| docs/navigate/advanced-programming/toc.yml | Adds the two new articles to the Advanced .NET programming navigation tree. |
| docs/standard/asynchronous-programming-patterns/snippets/synchronous-wrappers-for-async-methods/csharp/SyncWrappersForAsync.csproj | New C# snippet project for the sync-over-async article. |
| docs/standard/asynchronous-programming-patterns/snippets/synchronous-wrappers-for-async-methods/csharp/Program.cs | C# snippets demonstrating sync-over-async patterns, deadlock risk, and mitigations. |
| docs/standard/asynchronous-programming-patterns/snippets/synchronous-wrappers-for-async-methods/vb/SyncWrappersForAsync.vbproj | New VB snippet project for the sync-over-async article. |
| docs/standard/asynchronous-programming-patterns/snippets/synchronous-wrappers-for-async-methods/vb/Program.vb | VB snippets demonstrating sync-over-async patterns and mitigations. |
| docs/standard/asynchronous-programming-patterns/snippets/async-wrappers-for-synchronous-methods/csharp/AsyncWrappersForSync.csproj | New C# snippet project for the async-over-sync article. |
| docs/standard/asynchronous-programming-patterns/snippets/async-wrappers-for-synchronous-methods/csharp/Program.cs | C# snippets demonstrating Task.Run offloading vs scalability. |
| docs/standard/asynchronous-programming-patterns/snippets/async-wrappers-for-synchronous-methods/vb/AsyncWrappersForSync.vbproj | New VB snippet project for the async-over-sync article. |
| docs/standard/asynchronous-programming-patterns/snippets/async-wrappers-for-synchronous-methods/vb/Program.vb | VB snippets demonstrating Task.Run offloading vs scalability. |
.../standard/asynchronous-programming-patterns/synchronous-wrappers-for-asynchronous-methods.md
Outdated
Show resolved
Hide resolved
...onous-programming-patterns/snippets/synchronous-wrappers-for-async-methods/csharp/Program.cs
Outdated
Show resolved
Hide resolved
...nchronous-programming-patterns/snippets/synchronous-wrappers-for-async-methods/vb/Program.vb
Outdated
Show resolved
Hide resolved
...onous-programming-patterns/snippets/synchronous-wrappers-for-async-methods/csharp/Program.cs
Outdated
Show resolved
Hide resolved
...onous-programming-patterns/snippets/async-wrappers-for-synchronous-methods/csharp/Program.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…nto async-aweigh-1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Contributes to #17714
Port the first two articles for wrapping async methods in synchronous methods, and wrapping synchronous methods in asynchronous methods.
Internal previews