private async void DevicePoller_DeviceInitialized(object sender, DeviceEventArgs e) { try { await _Lock.WaitAsync(); var LedgerManager = LedgerManagers.FirstOrDefault(t => ReferenceEquals(t.LedgerHidDevice, e.Device)); if (LedgerManager == null) { LedgerManager = new LedgerManager(e.Device, CoinUtility, ErrorPromptDelegate); var tempList = new List <LedgerManager>(LedgerManagers) { LedgerManager }; LedgerManagers = new ReadOnlyCollection <LedgerManager>(tempList); if (_FirstLedgerTaskCompletionSource.Task.Status == TaskStatus.WaitingForActivation) { _FirstLedgerTaskCompletionSource.SetResult(LedgerManager); } LedgerInitialized?.Invoke(this, new LedgerManagerConnectionEventArgs(LedgerManager)); } } finally { _Lock.Release(); } }
public void Dispose() { if (disposed) { return; } disposed = true; _Lock.Dispose(); _DeviceListener.Stop(); _DeviceListener.Dispose(); foreach (var LedgerManager in LedgerManagers) { LedgerManager.Dispose(); } GC.SuppressFinalize(this); }
public LedgerManagerConnectionEventArgs(LedgerManager ledgerManager) { LedgerManager = ledgerManager; }