Griffin.Net.Channels.TcpChannel.CloseAsync C# (CSharp) Method

CloseAsync() public method

Signal channel to close.

Will wait for all data to be sent before closing.

public CloseAsync ( ) : Task
return Task
        public Task CloseAsync()
        {
            _socket.Shutdown(SocketShutdown.Send);
            var t = _closeEvent.WaitAsync(5000);

            // release again so that we can take reuse it internally
            t.ContinueWith(x =>
            {
                _closeEvent.Release();
                IsConnected = false;
            });

            return t;
        }