System.Net.WebSockets.WebSocketBase.OutstandingOperationHelper.CompleteOperation C# (CSharp) Method

CompleteOperation() public method

public CompleteOperation ( bool ownsCancellationTokenSource ) : void
ownsCancellationTokenSource bool
return void
            public void CompleteOperation(bool ownsCancellationTokenSource)
            {
                if (_isDisposed)
                {
                    // no-op if the WebSocket is already aborted
                    return;
                }

                CancellationTokenSource snapshot = null;

                lock (_thisLock)
                {
                    --_operationsOutstanding;
                    Debug.Assert(_operationsOutstanding >= 0, "'_OperationsOutstanding' must never be smaller than 0.");

                    if (ownsCancellationTokenSource)
                    {
                        snapshot = _cancellationTokenSource;
                        _cancellationTokenSource = null;
                    }
                }

                if (snapshot != null)
                {
                    snapshot.Dispose();
                }
            }