System.Net.WebSockets.WebSocketProtocolComponent.DrainActionQueue C# (CSharp) Method

DrainActionQueue() private static method

private static DrainActionQueue ( SafeHandle webSocketHandle, ActionQueue actionQueue ) : void
webSocketHandle System.Runtime.InteropServices.SafeHandle
actionQueue ActionQueue
return void
        private static void DrainActionQueue(SafeHandle webSocketHandle, ActionQueue actionQueue)
        {
            Debug.Assert(webSocketHandle != null && !webSocketHandle.IsInvalid,
                "'webSocketHandle' MUST NOT be NULL or INVALID.");

            IntPtr actionContext;
            IntPtr dummy;
            Action action;
            BufferType bufferType;

            while (true)
            {
                Interop.WebSocket.Buffer[] dataBuffers = new Interop.WebSocket.Buffer[1];
                uint dataBufferCount = 1;
                int errorCode = Interop.WebSocket.WebSocketGetAction(webSocketHandle,
                    actionQueue,
                    dataBuffers,
                    ref dataBufferCount,
                    out action,
                    out bufferType,
                    out dummy,
                    out actionContext);

                if (!Succeeded(errorCode))
                {
                    Debug.Assert(errorCode == 0, "'errorCode' MUST be 0.");
                    return;
                }

                if (action == Action.NoAction)
                {
                    return;
                }

                Interop.WebSocket.WebSocketCompleteAction(webSocketHandle, actionContext, 0);
            }
        }