System.Net.WebSockets.WebSocketBase.StartOnCloseReceived C# (CSharp) Method

StartOnCloseReceived() private method

private StartOnCloseReceived ( bool &thisLockTaken ) : bool
thisLockTaken bool
return bool
        private bool StartOnCloseReceived(ref bool thisLockTaken)
        {
            ThrowIfDisposed();

            if (IsStateTerminal(State) || State == WebSocketState.CloseReceived)
            {
                return false;
            }

            Monitor.Enter(_thisLock, ref thisLockTaken);
            if (IsStateTerminal(State) || State == WebSocketState.CloseReceived)
            {
                return false;
            }

            if (State == WebSocketState.Open)
            {
                _state = WebSocketState.CloseReceived;

                if (_closeReceivedTaskCompletionSource == null)
                {
                    _closeReceivedTaskCompletionSource = new TaskCompletionSource<object>();
                }

                return false;
            }

            return true;
        }