client.BeginReceive(state.buffer,0,StateObject.BufferSize,0,
new AsyncCallback(ReceiveCallback), state);
does not automatically call the ReceiveCallback method, this method is called when the operation is completed.
Meanwhile, the method that is called BeginReceivecontinues to be executed, doing everything that it does, and returns with joy, thereby removing itself from the stack.
When you use recursion, each call adds a stack frame (see the comment), which is not set until the called method returns, so the stack will grow until the recursion is complete.
Sweko source
share