Hy, I'm using the SocketAsyncEventArgsPool described on MSDN.
For each TCP Client i have an own pool(Stack) of 50 SocketAsyncEventArgs to write from the server to the Client. So, this works fine, but on restart the Client or the Server i have a Function that is sending many messages to the Client and for each message one SocketAsyncEventArgs is taken from my pool. When there are too many messages my Pool is empty and there is no free SocketAsyncEventArgs Object for sending und this message will not be send to the Client.
Is there any possibility to avoid this without increase my pool??? Thanks!!!
If the pool is empty, just create a fresh object. This should be a rare event. Performance should not be impacted.
You can also dynamically increase the pool size by adding the freshly created object back to the pool when it is no longer used. That way the pool size keeps increasing until it satisfies all demand.