Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CloseDevice() function causing the application to hang #138

Open
BQTHake003 opened this issue Apr 3, 2023 · 1 comment
Open

CloseDevice() function causing the application to hang #138

BQTHake003 opened this issue Apr 3, 2023 · 1 comment

Comments

@BQTHake003
Copy link

I am using a .NetFramework 4.8 Windows application where I have installed the HidLibrary version 3.3.40 from NuGet package manager. My operating system is Windows 10 pro 64-bit with build version 10.0.19045.

I am using System.Windows.Forms for my main form that includes Close button to close the device. Whenever, I trigger device close, the software execution triggers the CloseDevice() in the HidLibrary. I debugged the issue and the library is frozen exactly when trying to close one of the handles (ReadHandle) in CLoseDeviceIO(ReadHandle). More specifically, the indefinite blockage is happening in NativeMethods.CloseHandle(handle)

I can see that NativeMethods.CancelIoEx(handle, IntPtr.Zero) is triggered fine and returned successfully.

I tried cloning the library and point to latest master branch, and tried using different versions of .NetFramework 4.5 but nothing worked.

To be fair I have managed to close the device successfully but this wasn't stable at all. It was completely in deterministic behavior in that regards

@github-mem
Copy link

github-mem commented Sep 7, 2023

Check if handle is not null then close it:
if (handle != null) NativeMethods.CloseHandle(handle);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants