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

HttpWebRequest.BeginGetResponse example doesn't correctly follow the APM pattern #8662

Open
svick opened this issue Nov 25, 2022 · 1 comment
Labels
area-System.Net Pri3 Indicates issues/PRs that are low priority untriaged New issue has not been triaged by the area owner

Comments

@svick
Copy link
Contributor

svick commented Nov 25, 2022

Per @stephentoub's comment in microsoft/referencesource#177 (comment) regarding the documentation of HttpWebRequest.BeginGetResponse:

That code sample is buggy and does not correctly follow the APM pattern. BeginXx methods may complete the operation synchronously, which is why the IAsyncResult.CompletedSynchronously property exists. The callback needs to check that property, and if it's true, exit immediately and instead allow the BeginXx call site to perform the continuation. Otherwise, a string of synchronously completing operations may stack dive. The docs should be fixed

Also, I think it might be useful for this page to contain a prominent note pointing people to modern alternatives, namely async methods on HttpClient.

@issues-automation issues-automation bot added the Pri3 Indicates issues/PRs that are low priority label Nov 25, 2022
@ghost ghost added the untriaged New issue has not been triaged by the area owner label Nov 25, 2022
@ghost
Copy link

ghost commented Nov 25, 2022

Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

Issue Details

Per @stephentoub's comment in microsoft/referencesource#177 (comment) regarding the documentation of HttpWebRequest.BeginGetResponse:

That code sample is buggy and does not correctly follow the APM pattern. BeginXx methods may complete the operation synchronously, which is why the IAsyncResult.CompletedSynchronously property exists. The callback needs to check that property, and if it's true, exit immediately and instead allow the BeginXx call site to perform the continuation. Otherwise, a string of synchronously completing operations may stack dive. The docs should be fixed

Also, I think it might be useful for this page to contain a prominent note pointing people to modern alternatives, namely async methods on HttpClient.

Author: svick
Assignees: -
Labels:

area-System.Net, untriaged, Pri3

Milestone: -

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-System.Net Pri3 Indicates issues/PRs that are low priority untriaged New issue has not been triaged by the area owner
Projects
None yet
Development

No branches or pull requests

1 participant