-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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 BeginRead different behaviour on .NET Core vs Framework #177
Comments
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, but this isn't a bug in .NET Core nor is it configurable. .NET Core is simply faster and much more likely for operations to complete synchronously. |
Thanks, got it. I found your comment here dotnet/runtime#29024 also If anyone works in Microsoft or anyone knows anybody works in Microsoft About this case the some relevant answer it to look at when it is possible to find Notes to Callers Hope that somebody will find that via google also. |
Most things are open now in .Net, so we don't have to rely on Microsoft employees. Namely:
|
@thenik I wonder what is the reason you are using |
@antonfirsov it is an old legacy project ( https://mydataprovider.com web scraper ). |
Hello ,
If you run this code sample
https://learn.microsoft.com/en-us/dotnet/api/system.net.httpwebrequest.begingetresponse?view=net-7.0
on .net framework 462 or 472 it calls BeginRead on a ThreadPool and it is standart behavious that I expect.
but
on .net core 2.2, 3 and above it calls BeginRead on a stack and it is wrong behaviour because if you need to load a big file it will rise an exception StackOverflow.
So question : how to run BeginRead for Stream from GetResponseStream on a ThreadPool on .NET Core 6/7?
Here is my small modification of original code from the sample that calls stackoverflow at .net core 6 or .net core 7
The text was updated successfully, but these errors were encountered: