| re: Closing Blocked Thread
Well I've found a solution that is at least more satisfactory. I rewrote my Reader class to be intstance based rather than a static class, and instead of running in a separate looped thread, I do an async read on the device, then close/open the device again, and run the read function again from my callback:
private void Listen()
{
device.Read(new HidDevice.ReadCallback(OnDataReceived));
}
private void OnDataReceived(HidDeviceData hid_data)
{
if (this.DataReceived != null){this.DataReceived(this, new HIDDataEventArgs(hid_data));}
device.CloseDevice();
device.OpenDevice();
Listen();
}
This works for my form-based app to edit different remote profiles and assign actions to buttons, but will not do for my service to convert the hid data received to keystrokes using keyb_event. Any ideas? I'll gladly give my code to anyone interested, as this is a personal project, not commercial...
|