Giter Club home page Giter Club logo

Comments (5)

stephentoub avatar stephentoub commented on June 17, 2024

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.

from referencesource.

thenik avatar thenik commented on June 17, 2024

Thanks, got it.
It is clear how it works now =)
Funny that this shoud work from .NET 4.5 but on practice I do not see that even at .NET 4.8 .
Only .net core sends CompletedSynchronously == true .

I found your comment here dotnet/runtime#29024 also
and it has the same story.

If anyone works in Microsoft or anyone knows anybody works in Microsoft
ask Microsoft to adjust this samples =) because it is wrong now.

About this case the some relevant answer it to look at
https://learn.microsoft.com/en-us/dotnet/api/system.iasyncresult.completedsynchronously?view=net-7.0

when it is possible to find

Notes to Callers
Use this property to determine if the asynchronous operation completed synchronously. For example, this property can return true for an asynchronous I/O operation if the I/O request was small.

Hope that somebody will find that via google also.
Thanks for your help again!
Best regards.
Nik

from referencesource.

svick avatar svick commented on June 17, 2024

@thenik

If anyone works in Microsoft or anyone knows anybody works in Microsoft
ask Microsoft to adjust this samples =) because it is wrong now.

Most things are open now in .Net, so we don't have to rely on Microsoft employees. Namely:

  1. Anyone can open an issue, making sure the problem is properly tracked. I just did that at dotnet/dotnet-api-docs#8662.
  2. Anyone can open a Pull Request, fixing the documentation. If you want to do that, click the pencil icon on the documentation page, then click another pencil icon on the opened GitHub page.

from referencesource.

antonfirsov avatar antonfirsov commented on June 17, 2024

@thenik I wonder what is the reason you are using HttpWebRequest and not HttpClient?

from referencesource.

thenik avatar thenik commented on June 17, 2024

@antonfirsov it is an old legacy project ( https://mydataprovider.com web scraper ).
Started since Microsoft .NET Framework 2.0 .
I migrate it to .net 6. So it is hard to use HttpClient.
Additionally , in a real life I saw many times when
WebClient, HttpClient, HttpWebRequest do not work as expected,
all these classes can hang-up under the high load.
So we if you want a reliable software (webscraper) you have to managing all http requests itself.

from referencesource.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.