/// <summary> /// Clears this out when the removed /// event happens /// </summary> private void mScale_Removed() { if (mScale != null) { mScale.Dispose(); mScale = null; } }
public static async Task <SendCommandandResponseResult> SendCommandandResponse(List <HidParam> hidParams, byte[] send, int timeoutms, EventHandler keepalive) { var result = new SendCommandandResponseResult(); IHidDevice hidDevice = null; try { hidDevice = CTAPHID.find(hidParams); if (hidDevice == null) { return(null); } using (var openedDevice = await CTAPHID.OpenAsync(hidDevice)) { openedDevice.ReceiveResponseTotalTimeoutMs = timeoutms; openedDevice.KeepAlive += keepalive; result.responseData = await openedDevice.CborAsync(send); result.isTimeout = openedDevice.isReceiveResponseTotalTimeout; } } catch (Exception) { } finally { if (hidDevice != null) { hidDevice.Dispose(); } } return(result); }
/// <summary> /// dispose the device /// </summary> public void Dispose() { if (IsReady) { device.Dispose(); } }
protected override void Dispose(bool disposing) { if (closeDeviceOnDispose) { device.Dispose(); } }
public void Dispose() { _deviceListener.DeviceDisconnected -= DevicePoller_DeviceDisconnected; _deviceListener.DeviceInitialized -= DevicePoller_DeviceInitialized; _deviceListener.Dispose(); _rs28Device?.Dispose(); }
public void Dispose() { _HidDevice?.Dispose(); }