예제 #1
0
    public async Task AddNewFiltersAsync(IEnumerable <FilterModel> filters, CancellationToken cancel)
    {
        var successAny = false;

        foreach (var filter in filters)
        {
            var success = false;

            using (await IndexLock.LockAsync(cancel).ConfigureAwait(false))
            {
                success = TryProcessFilter(filter, enqueue: true);
            }
            successAny = successAny || success;

            if (success)
            {
                NewFilter?.Invoke(this, filter);                 // Event always outside the lock.
            }
        }

        if (successAny)
        {
            AbandonedTasks.AddAndClearCompleted(TryCommitToFileAsync(TimeSpan.FromSeconds(3), cancel));
        }
    }
예제 #2
0
        public ConnectHardwareWalletViewModel(string walletName, WalletManagerViewModel walletManagerViewModel)
        {
            _message       = "";
            WalletName     = walletName;
            WalletManager  = walletManagerViewModel.Model;
            Wallets        = walletManagerViewModel.Wallets;
            AbandonedTasks = new AbandonedTasks();
            CancelCts      = new CancellationTokenSource();

            NextCommand = ReactiveCommand.Create(() =>
            {
                if (DetectedDevice is { } device)
                {
                    NavigateToNext(device);
                    return;
                }

                StartDetection();
            });

            OpenBrowserCommand = ReactiveCommand.CreateFromTask(async() =>
                                                                await IoHelpers.OpenBrowserAsync("https://docs.wasabiwallet.io/using-wasabi/ColdWasabi.html#using-hardware-wallet-step-by-step"));

            NavigateToExistingWalletLoginCommand = ReactiveCommand.Create(() =>
            {
                var navBar = NavigationManager.Get <NavBarViewModel>();

                if (ExistingWallet is { } && navBar is { })
예제 #3
0
    public async Task <FilterModel> RemoveLastFilterAsync(CancellationToken cancel)
    {
        FilterModel?filter = null;

        using (await IndexLock.LockAsync(cancel).ConfigureAwait(false))
        {
            filter = ImmatureFilters.Last();
            ImmatureFilters.RemoveLast();
            if (SmartHeaderChain.TipHeight != filter.Header.Height)
            {
                throw new InvalidOperationException($"{nameof(SmartHeaderChain)} and {nameof(ImmatureFilters)} are not in sync.");
            }
            SmartHeaderChain.RemoveTip();
        }

        Reorged?.Invoke(this, filter);

        AbandonedTasks.AddAndClearCompleted(TryCommitToFileAsync(TimeSpan.FromSeconds(3), cancel));

        return(filter);
    }
예제 #4
0
        public ConnectHardwareWalletViewModel(string walletName)
        {
            _message       = "";
            WalletName     = walletName;
            Wallets        = UiServices.WalletManager.Wallets;
            AbandonedTasks = new AbandonedTasks();
            CancelCts      = new CancellationTokenSource();

            EnableBack = true;

            NextCommand = ReactiveCommand.Create(OnNext);

            OpenBrowserCommand = ReactiveCommand.CreateFromTask(async() =>
                                                                await IoHelpers.OpenBrowserAsync("https://docs.wasabiwallet.io/using-wasabi/ColdWasabi.html#using-hardware-wallet-step-by-step"));

            NavigateToExistingWalletLoginCommand = ReactiveCommand.Create(execute: OnNavigateToExistingWalletLogin);

            this.WhenAnyValue(x => x.Message)
            .ObserveOn(RxApp.MainThreadScheduler)
            .Subscribe(message => ConfirmationRequired = !string.IsNullOrEmpty(message));
        }
예제 #5
0
 public RunningTasks(AbandonedTasks taskCollection)
 {
     taskCollection.AddAndClearCompleted(Completion.Task);
 }