BF2Statistics.Net.BufferManager.ReleaseBuffer C# (CSharp) Method

ReleaseBuffer() public method

Releases Buffer space assigned to a token so that it can be assingned to a new SAEA
public ReleaseBuffer ( SocketAsyncEventArgs args ) : void
args System.Net.Sockets.SocketAsyncEventArgs The SocketEventArgs object that we are releasing buffer space from
return void
        public void ReleaseBuffer(SocketAsyncEventArgs args)
        {
            // Check for dispose
            CheckDisposed();

            // Grab the SAEA user token, which should be a BufferDataToken
            BufferDataToken Token = args.UserToken as BufferDataToken;
            if (Token == null)
                throw new Exception("The SocketAsyncEventArgs.UserToken was not a valid instance of BufferDataToken");

            // Add the free buffer space back
            FreeBufferSpace.Push(Token);

            // Try and reset buffer
            try { args.SetBuffer(null, 0, 0); }
            catch (ObjectDisposedException) { }
        }