I'm using your excellent Generic HID 6.0 code to transfer data to a device. The data is typically ~150 bytes so I chunk it up into 64 byte pieces and sent three output reports. After I send the last output report, the device will process the data (~ 30 seconds or so) and then respond with an input report. Now I have three pieces of data that I need to send to the device and my pseudocode looks like this:
foreach (byte[] byteArray in listOfByteArrays)
{
// split byteArray into 64 byte chunks
// loop to write each chunk as an output report to device
// try to read an input report from device; it may take the device ~30 seconds to respond so wait until we get a response before we continue the foreach loop
}
The async/await stuff in C# 5.0 is new to me so I'm not entirely clear about how works. As you can see, however, I need to be able to wait until I get the input report from the device before I begin processing the next byte array in listOfArrays. Is there an easy way to wait for an async operation to complete?