In C# with async ctp or the vs.net 2011 beta we can write recursive code like this:
public async void AwaitSocket()
{
var socket = await this.AcceptSocketAsy
From the discussion above, I guess something like this will be the best approach. Please give feedback
public async void StartAcceptingSockets()
{
await Task.Yield();
// return to caller so caller can start up other processes/agents
// TaskEx.Yield in async ctp , Task.Yield in .net 4.5 beta
while(true)
{
var socket = await this.AcceptSocketAsync();
HandleAsync(socket);
//make handle call await Task.Yield to ensure the next socket is accepted as fast
//as possible and dont wait for the first socket to be completely handled
}
}
private async void HandleAsync(Socket socket)
{
await Task.Yield(); // return to caller
... consume the socket here...
}