views:

578

answers:

2

I'm may be just misunderstanding something fundamental here but...

Senario: I call System.Net.Sockets.NetworkStream's BeginRead method and my machine receives a response/request from a network device. The runtime runs my callback in its own thread. Before this thread can call EndRead, the machine receives another response/request.

Question: Will the runtime call my callback in another thread immediately or wait for me to call EndRead and then BeginRead again?

+1  A: 

It should run the callback method immediately in another thread. (hence the asynchronous rather than blocking calls).

Justin Niessner
+2  A: 

You have to call EndRead and then BeginRead again to handle the new incoming message.

Aidan