示例#1
0
        private async void DevicePoller_DeviceDisconnected(object sender, DeviceEventArgs e)
        {
            try
            {
                await _Lock.WaitAsync().ConfigureAwait(false);

                var trezorManager = TrezorManagers.FirstOrDefault(t => ReferenceEquals(t.Device, e.Device));

                if (trezorManager == null)
                {
                    return;
                }

                TrezorDisconnected?.Invoke(this, new TrezorManagerConnectionEventArgs <TMessageType>(trezorManager));

                trezorManager.Dispose();

                var tempList = new List <T>(TrezorManagers);

                _ = tempList.Remove(trezorManager);

                TrezorManagers = new ReadOnlyCollection <T>(tempList);
            }
            finally
            {
                _ = _Lock.Release();
            }
        }
示例#2
0
 private void DevicePoller_DeviceDisconnected(object sender, DeviceEventArgs e)
 {
     TrezorDevice = null;
     TrezorDisconnected?.Invoke(this, new EventArgs());
 }