Callbacks are independent as they're invoked on the thread-pools IO completion workers.
If you're interested, you can see that in the source code. This particular method is for the Socket class (which TcpClient and UdpClient use internally), where overlapped IO is used to invoke the callback (see the comment on top of asyncResult.SetUnmanagedStructures invocation:
private void DoBeginReceiveFrom(byte[] buffer, int offset,
int size, SocketFlags socketFlags,
EndPoint endPointSnapshot, SocketAddress
socketAddress, OverlappedAsyncResult asyncResult)
{
EndPoint oldEndPoint = m_RightEndPoint;
SocketError errorCode = SocketError.SocketError;
try
{
// Set up asyncResult for overlapped WSARecvFrom.
// This call will use completion ports on WinNT and Overlapped IO on Win9x.
asyncResult.SetUnmanagedStructures(
buffer, offset, size,
socketAddress, true /* pin remoteEP*/,
ref Caches.ReceiveOverlappedCache);
asyncResult.SocketAddressOriginal = endPointSnapshot.Serialize();
if (m_RightEndPoint == null)
{
m_RightEndPoint = endPointSnapshot;
}
int bytesTransferred;
errorCode = UnsafeNclNativeMethods.OSSOCK.WSARecvFrom(
m_Handle,
ref asyncResult.m_SingleBuffer,
1,
out bytesTransferred,
ref socketFlags,
asyncResult.GetSocketAddressPtr(),
asyncResult.GetSocketAddressSizePtr(),
asyncResult.OverlappedHandle,
IntPtr.Zero );
if (errorCode!=SocketError.Success)
{
errorCode = (SocketError)Marshal.GetLastWin32Error();
}
}
catch (ObjectDisposedException)
{
m_RightEndPoint = oldEndPoint;
throw;
}
finally
{
errorCode = asyncResult.CheckAsyncCallOverlappedResult(errorCode);
}
}
BeginReceiveon?