コード例 #1
0
        public int SubmitNextRead()
        {
            // Pull from head of Completed list and push to end of Outstanding list
            IsoTransferItem isoTransferItem = Completed.First.Value;

            Completed.RemoveFirst();
            Outstanding.AddLast(isoTransferItem);

            // If managing a start frame manually, set it here and update the the frame counter for the next transfer.
            SetNextFrameNumber(isoTransferItem);

            // Prepare the OvlK handle to be submitted.
            OvlPool.ReUse(isoTransferItem.Ovl);

            // The data buffer was pinned earlier when it was allocated.  Always pin managed memory before using it
            // in an asynchronous function to keep the framework from tampering with it.
            Usb.IsoReadPipe(PipeInfo.PipeId,
                            isoTransferItem.Buffer,
                            DataBufferSize,
                            isoTransferItem.Ovl,
                            isoTransferItem.Iso.Handle);

            int errorCode = Marshal.GetLastWin32Error();

            // 997 is ERROR_IO_PENDING. For async, this means so far so good.
            // IE: The transfer is submitted but we won't know if a problem occurs until it is completed.
            if (errorCode != ErrorCodes.IoPending)
            {
                return(errorCode);
            }

            TotalSubmittedCount++;

            return(0);
        }