System.Net.HttpListener.DisconnectAsyncResult.StartOwningDisconnectHandling C# (CSharp) Method

StartOwningDisconnectHandling() private method

private StartOwningDisconnectHandling ( ) : bool
return bool
            internal bool StartOwningDisconnectHandling()
            {
                int oldValue;

                SpinWait spin = new SpinWait();
                while ((oldValue = Interlocked.CompareExchange(ref _ownershipState, 1, 0)) == 2)
                {
                    // Must block until it equals 3 - we must be in the callback right now.
                    spin.SpinOnce();
                }

                Debug.Assert(oldValue != 1, "StartOwningDisconnectHandling called twice.");
                return oldValue < 2;
            }