In my code I have a loop:
private static void DoProtocol(USBH_RawDevice.Pipe inPipe, USBH_RawDevice.Pipe outPipe)
{
var inBuffer = new byte[inPipe.PipeEndpoint.wMaxPacketSize];
var outBuffer = new byte[outPipe.PipeEndpoint.wMaxPacketSize];
int bytesTransferred;
while (true)
{
bytesTransferred = inPipe.TransferData(inBuffer, 0, 1);
if (bytesTransferred > 0)
{
// Do stuff
}
}
}
Is there an efficient blocking way to do this? That is, most of the time TransferData is returning 0 and nothing needs to be done, so the loop is just spinning.