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

CancelIO() public method

public CancelIO ( ) : void
return void
            public void CancelIO()
            {
                CancellationTokenSource cancellationTokenSourceSnapshot = null;

                lock (_thisLock)
                {
                    if (_operationsOutstanding == 0)
                    {
                        return;
                    }

                    cancellationTokenSourceSnapshot = _cancellationTokenSource;
                }

                if (cancellationTokenSourceSnapshot != null)
                {
                    try
                    {
                        cancellationTokenSourceSnapshot.Cancel();
                    }
                    catch (ObjectDisposedException)
                    {
                        // Simply ignore this exception - There is apparently a rare race condition
                        // where the cancellationTokensource is disposed before the Cancel method call completed.
                    }
                }
            }