Пример #1
0
 /// <summary>
 /// Clears this out when the removed
 /// event happens
 /// </summary>
 private void mScale_Removed()
 {
     if (mScale != null)
     {
         mScale.Dispose();
         mScale = null;
     }
 }
Пример #2
0
        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);
        }
Пример #3
0
 /// <summary>
 /// dispose the device
 /// </summary>
 public void Dispose()
 {
     if (IsReady)
     {
         device.Dispose();
     }
 }
Пример #4
0
 protected override void Dispose(bool disposing)
 {
     if (closeDeviceOnDispose)
     {
         device.Dispose();
     }
 }
Пример #5
0
 public void Dispose()
 {
     _deviceListener.DeviceDisconnected -= DevicePoller_DeviceDisconnected;
     _deviceListener.DeviceInitialized  -= DevicePoller_DeviceInitialized;
     _deviceListener.Dispose();
     _rs28Device?.Dispose();
 }
Пример #6
0
 public void Dispose()
 {
     _HidDevice?.Dispose();
 }