Author Topic: Bug in Generichid_cs (InvalidOverlappedToPinvoke)  (Read 38654 times)

Dave

  • Member
  • ***
  • Posts: 3
Re: Bug in Generichid_cs (InvalidOverlappedToPinvoke)
« Reply #15 on: September 06, 2011, 05:06:15 pm »
Hello,

Just wondering if this "InvalidOverlappedToPinvoke" issue was ever resolved?  If not, does anyone have any new ideas for its resolution?  Is it really a problem?

Best regards,

Dave

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 2856
    • Lakeview Research
Re: Bug in Generichid_cs (InvalidOverlappedToPinvoke)
« Reply #16 on: September 06, 2011, 05:29:14 pm »
I think the discussion in this thread pretty much explains the situation. My HID page has both the Filestream and ReadFile/WriteFile versions.

Jan

elanTry

  • Member
  • ***
  • Posts: 1
Re: Bug in Generichid_cs (InvalidOverlappedToPinvoke)
« Reply #17 on: October 18, 2011, 05:37:50 am »
The way I have implemented the timeout uses a ManualResetEvent, which is a .NET class.  My x2 version above also uses the ManualResetEvent to implement the timeout. 

Hey guys,
Just a little question here. :)
Why do you use ManualResetEvent instead of AutoResetEvent? Isn't it much prone to lose reports during the event waiting? 'Cause in my scenario I found it's seems to be losing data during the event waiting...
Just curious for that, thanks.

elanTry

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 2856
    • Lakeview Research
Re: Bug in Generichid_cs (InvalidOverlappedToPinvoke)
« Reply #18 on: October 18, 2011, 06:17:27 pm »
Thank you for this suggestion!

Jan

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 2856
    • Lakeview Research
Re: Bug in Generichid_cs (InvalidOverlappedToPinvoke)
« Reply #19 on: February 11, 2013, 01:03:01 pm »
New version of Generic HID application using asynchronous Filestreams (.NET 4.5) here:

http://www.lvr.com/forum/index.php?topic=1039.0

nanobyte

  • Member
  • ***
  • Posts: 1
Re: Bug in Generichid_cs (InvalidOverlappedToPinvoke)
« Reply #20 on: February 10, 2014, 06:24:04 am »
Hi,

since I learned so much from your discussion and using Generic_HID, I would like to share something I found out, or at least I think I found out.

To overcome the issue of blocking FileStreams I just separated the reading and writing to an HID into a thread for reading and a method for writing.
The trick (if any) was to provide two different SafeFileHandles, the first opened for read Access only,  the second for write Access.
This allows for concurrently reading and writing from and to the same HID.

If there is further interest, I will post my source code as well.

Regards,
Frank