Exemple #1
0
 public void Dispose()
 {
     _deviceListener.DeviceDisconnected -= DevicePoller_DeviceDisconnected;
     _deviceListener.DeviceInitialized  -= DevicePoller_DeviceInitialized;
     _deviceListener.Dispose();
     _rs28Device?.Dispose();
 }
Exemple #2
0
        private void OnTaskCanceled(IBackgroundTaskInstance sender, BackgroundTaskCancellationReason reason)
        {
            if (_deferral != null)
            {
                _source.Cancel();
                _listener.Dispose();

                _deferral.Complete();
                _deferral = null;
            }
        }
Exemple #3
0
        /// <summary>
        /// Starts the device listener that manages the connection and disconnection of devices
        /// </summary>
        public void Start(bool restart)
        {
            if (restart && _DeviceListener != null)
            {
                LedgerManagers = new ReadOnlyCollection <IManagesLedger>(new List <IManagesLedger>());
                _DeviceListener.DeviceDisconnected -= DevicePoller_DeviceDisconnected;
                _DeviceListener.DeviceInitialized  -= DevicePoller_DeviceInitialized;
                _DeviceListener.Dispose();
                _DeviceListener = null;
            }

            if (_DeviceListener == null)
            {
                _DeviceListener = new DeviceListener(DeviceDefinitions, PollInterval)
                {
                    Logger = new DebugLogger()
                };

                _DeviceListener.DeviceDisconnected += DevicePoller_DeviceDisconnected;
                _DeviceListener.DeviceInitialized  += DevicePoller_DeviceInitialized;
                _DeviceListener.Start();
            }
        }
        private void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }

            if (disposing)
            {
                _deviceListener.DeviceInitialized  -= DeviceInitializedHandler;
                _deviceListener.DeviceDisconnected -= DeviceDisconnectedHandler;
                _deviceListener.Dispose();

                _devices.Values.ForEach(device => device.Dispose());
            }

            _disposed = true;
        }
Exemple #5
0
        public void Dispose()
        {
            if (_disposed)
            {
                return;
            }
            _disposed = true;

            _Lock.Dispose();
            _DeviceListener.Stop();
            _DeviceListener.Dispose();

            foreach (var trezorManager in TrezorManagers)
            {
                trezorManager.Dispose();
            }

            GC.SuppressFinalize(this);
        }
Exemple #6
0
        public override async Task LoadDevicesAsync()
        {
            var legacyHid = new FilterDeviceDefinition(vendorId: LOGITECH_VENDOR_ID, usagePage: 0xFF00)
                            .CreateWindowsHidDeviceFactory();

            var modernHid = new FilterDeviceDefinition(vendorId: LOGITECH_VENDOR_ID, usagePage: 0xFF43)
                            .CreateWindowsHidDeviceFactory();

            var factories = legacyHid.Aggregate(modernHid);

            var deviceDefinitions = (await factories.GetConnectedDeviceDefinitionsAsync().ConfigureAwait(false)).ToList();

            _LogiDevices.Clear();

            _deviceListener?.Dispose();
            _deviceListener = new DeviceListener(factories, 1000, null);
            _deviceListener.DeviceInitialized  += _deviceListener_DeviceInitialized;
            _deviceListener.DeviceDisconnected += _deviceListener_DeviceDisconnected;

            _deviceListener.Start();
        }