2
Reply

async reading using beginread

Don Kooker

Don Kooker

Apr 6 2008 1:16 AM
7.6k
A few questions as to how beginread on a tcpclient or socket. If I start beginread, I believe the thread comes from the thread pool. Does the thread start when beginread is called, when data starts arriving, or when the specified number of bytes are recd and the ascyn callback method is started? The reason I ask, is I am wondering if I have a large number of connections reading and the clients that are sending data are slow (or not at all), will the thread pool quicklty fill up with threads that aren't doing anything waiting on data to be recd from clients?

The other related question I have is related to how to cleanly shutdown if there are async reads going on. Can you just close the tcpclient down from the main thread and the async readers go away gracefully, or do you have to do some sort of explicit locking on something like the tcpclient itself?

Answers (2)