Must call EndRead() in ALL cases?

前端 未结 1 1207
粉色の甜心
粉色の甜心 2021-01-18 04:39

Related to asynchronous IO using a (bidirectional) NetworkStream, MSDN says that \"EndRead must be called once for every call to BeginRead.\"

Is this true even for c

相关标签:
1条回答
  • 2021-01-18 05:29

    GCHandles pinning your buffers and some other unmanaged resources are released by the completion port callback. The unmanaged OVERLAPPED structure will hang around until the IAsyncResult gets finalized. This may be tolerable if the network load in your application is not large, but may become a problem if your application handles many connections per second, because finalization happens only after a full GC collection and on a separate thread.

    NB: these are implementation details, obtained with Reflector. Caveat emptor.

    0 讨论(0)
提交回复
热议问题