In what thread context are .NET 3.5 SendAsync and ReceiveAsync calls made?

Are SendAsync and ReceiveAsync using I / O completion ports?

+4
source share
1 answer

Well, the I / O completion ports work, waiting for the completion procedure to complete as an APC for the workflow in ThreadPool (SocketAsyncEventArgsPool). So context is some kind of workflow that has been created.

As for your actual question, I cannot imagine that they would use anything other than I / O ports, this would be very inefficient otherwise; however, this is basically an implementation detail - no matter how they do it, the reality is that the notification is in an arbitrary context (i.e. you don't know anything about which stream you are in), so you need to do something streaming, a safe way in your completion routine.

For good scalability, I would also try to minimize the work done in this subroutine, complete I / O as soon as possible - if you need to do other work, use a separate thread pool, in which you can queue up for real computations on.

+2
source

Source: https://habr.com/ru/post/1301296/


All Articles