Jan,
In searching for an answer to this, I came across
https://github.com/sky8273/GenericHid . This code is primarily yours from an earlier release, 5.0. In it I noticed the code for creating the file handle:
hidHandle = FileIo.CreateFile(myDevicePathName, FileIo.GenericRead | FileIo.GenericWrite, FileIo.FileShareRead | FileIo.FileShareWrite, IntPtr.Zero, FileIo.OpenExisting, FileIo.FileFlagOverlapped, IntPtr.Zero);
The flag 'FileFlagOverlapped' is used which is not in the current version 6.2. I had to add a definition for it in FileIODeclarations.cs -
internal const Int32 FileFlagOverlapped = 0X40000000;
Then I was able to create the FIleStream object with the Async parameter set to 'true', and it compiles and runs okay.
_deviceData = new FileStream(_hidHandle, FileAccess.Read | FileAccess.Write, _myHid.Capabilities.InputReportByteLength, true);
FileStream.ReadAsync() is used to read IN reports, and is called repeatedly as IN reports are received - so it is always running. ReadTimeout is set to -1, so there is no timeout. The HID device can send an IN report at any time and it will be received.
In the meantime an OUT report can be sent at any time (with button click for instance) using FileStream.WriteAsync(). It is not blocked.
There is one problem however - for some unknown reason the first OUT report will not be sent until a second OUT report is written. The host driver code seems to buffer the the first report, and both reports are sent only when the second one is written. This behavior continues, i.e. a third report will be buffered until a fourth report is written, etc.
This problem does not occur however if OUT reports are sent synchronously using FileStream.Write().
Do you know what causes this behavior?