private IOHIDDeviceScheduleWithRunLoop ( |
||
device | ||
runLoop | ||
runLoopMode | ||
Résultat | void |
unsafe void ReadThread() { if (!HandleAcquire()) { return; } _readRunLoop = NativeMethods.CFRunLoopGetCurrent(); try { var inputCallback = new NativeMethods.IOHIDReportCallback(ReadThreadCallback); var removalCallback = new NativeMethods.IOHIDCallback(RemovalCallback); byte[] inputReport = new byte[Device.GetMaxInputReportLength()]; fixed(byte *inputReportBytes = inputReport) { NativeMethods.IOHIDDeviceRegisterInputReportCallback(_handle, (IntPtr)inputReportBytes, (IntPtr)inputReport.Length, inputCallback, IntPtr.Zero); NativeMethods.IOHIDDeviceRegisterRemovalCallback(_handle, removalCallback, IntPtr.Zero); NativeMethods.IOHIDDeviceScheduleWithRunLoop(_handle, _readRunLoop, NativeMethods.kCFRunLoopDefaultMode); NativeMethods.CFRunLoopRun(); NativeMethods.IOHIDDeviceUnscheduleFromRunLoop(_handle, _readRunLoop, NativeMethods.kCFRunLoopDefaultMode); } GC.KeepAlive(this); GC.KeepAlive(inputCallback); GC.KeepAlive(removalCallback); GC.KeepAlive(_inputQueue); } finally { HandleRelease(); } }