I tried to add in a Button1 for read operation only.
I clicked on "Find My Device" followed by "Button1" for "no incoming data" operation. It works with this message: "The attempt to read a report timed out.".
Then I clicked on "Find My Device" again followed by "Once". There is incoming data but somehow during fileStreamdevicedata.EndRead(ar), it gives error.
Unexpected Exception: Either the IAsyncResult object did not come from the corresponding async method on this type, or EndRead was called multiple times with the same IAsync Result.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim inputReportBuffer() As Byte = Nothing
Dim ar As IAsyncResult = Nothing
transferInProgress = True
' Timeout if no report is available.
If (MyHid.Capabilities.InputReportByteLength > 0) Then
' Set the size of the Input report buffer.
' Subtract 1 from the value in the Capabilities structure because
' the array begins at index 0.
Array.Resize(inputReportBuffer, MyHid.Capabilities.InputReportByteLength)
tmrReadTimeout.Start()
If (fileStreamdevicedata.CanRead) Then
fileStreamdevicedata.BeginRead(inputReportBuffer, 0, inputReportBuffer.Length, New AsyncCallback(AddressOf GetInputReportData), inputReportBuffer)
Else
CloseCommunications()
lstResults.Items.Add("The attempt to read an Input report has failed.")
End If
End If
End Sub