MelbourneDeveloper / Device.Net

A C# cross platform connected device framework
MIT License
628 stars 121 forks source link

Enable async I/O handles to support cancellation tokens #215

Closed ionothanus closed 3 years ago

ionothanus commented 3 years ago

Resolves #188 by opening handles in asynchronous (overlapped) mode.

MelbourneDeveloper commented 3 years ago

Woo! I never thought I'd see the day when someone actually fixes something like this. Thanks. I'll take a look soon.

MelbourneDeveloper commented 3 years ago

@ionothanus this certainly looks like you're on the right path. However, I've tried something similar before and it failed inexplicably. Have you tested this with a device?

If not, I will give it a go when I have time.

ionothanus commented 3 years ago

I’ve been using it successfully with a mechanical keyboard. Certainly wouldn’t hurt to have someone else try it, though. I’m not sure if there have been any changes to .NET that have enabled this to work successfully where it didn’t before.

MelbourneDeveloper commented 3 years ago

@ionothanus I thank you very much. I tested it on two HID devices and it works. I haven't proved that cancellation tokens work yet, but I'm going to close the issue until someone reports otherwise.

Were you able to test cancellation tokens?

MelbourneDeveloper commented 3 years ago

@ionothanus this is now part of the 4.1.0 version

ionothanus commented 3 years ago

Fantastic! Yes, I went down this path because my use case needed cancellation tokens, and I can confirm this enabled them to work for me.