title: Non blocking alternative to Readfile() from fileapi.h ? C#
body: <p>Currently reading data packages from a HID_DEVICE. In a windows desktop application c#.
  When the device is on, everything is perfect. Packages are readed and handled as pretended.
  The problem comes when the device is connected but not turned on.
  The application gets stuck in the readfile () because it has nothing to read.</p>
  <p>So my question is:</p>
  <p>Is there any way to see if the Readfile() has something to read, before calling it?
  or failing that, some non-blocking alternative to Readfile()</p>
  <p>I have tried adding a timeout, but this seems to mess up the rest of the application.
  Took the idea from here:
  <a href="https://stackoverflow.com/questions/53362883/implementing-a-readfile-with-a-timeout-inducing-too-much-cpu-ussage">Implementing a ReadFile with a timeout inducing too much CPU ussage</a></p>
  <p>Readfile() function documentation:
  <a href="https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-readfile" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-readfile</a></p>
  <p>Edit_0: Runing into the same problem with filestream as sugested in comments.
  Can i somehow check if the connected hid device is turned on/off?</p>
  <p>Thanks in advance.</p>