use RxUI Scheduler for dispatching onto ui thread
to rebuild the lists to display on ui.
MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/HistoryTabViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/HistoryTabViewModel.cs
@@ -8,6 +8,7 @@ using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Linq;
+using System.Reactive.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
@@ -31,9 +32,18 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
Transactions = new ObservableCollection<TransactionViewModel>();
RewriteTable();
- Global.WalletService.NewBlockProcessed += WalletService_NewBlockProcessed;
- Global.WalletService.Coins.CollectionChanged += Coins_CollectionChanged;
- Global.WalletService.CoinSpentOrSpenderConfirmed += WalletService_CoinSpent;
+ var coinsChanged = Observable.FromEventPattern(Global.WalletService.Coins, nameof(Global.WalletService.Coins.HashSetChanged));
+ var newBlockProcessed = Observable.FromEventPattern(Global.WalletService, nameof(Global.WalletService.NewBlockProcessed));
+ var coinSpent = Observable.FromEventPattern(Global.WalletService, nameof(Global.WalletService.CoinSpentOrSpenderConfirmed));
+
+ coinsChanged
+ .Merge(newBlockProcessed)
+ .Merge(coinSpent)
+ .ObserveOn(RxApp.MainThreadScheduler)
+ .Subscribe(o =>
+ {
+ RewriteTable();
+ });
this.WhenAnyValue(x => x.SelectedTransaction).Subscribe(async transaction =>
{
@@ -121,21 +131,6 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
}
}
- private void WalletService_NewBlockProcessed(object sender, Block e)
- {
- Dispatcher.UIThread.InvokeAsync(() => RewriteTable());
- }
-
- private void Coins_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
- {
- Dispatcher.UIThread.InvokeAsync(() => RewriteTable());
- }
-
- private void WalletService_CoinSpent(object sender, SmartCoin e)
- {
- Dispatcher.UIThread.InvokeAsync(() => RewriteTable());
- }
-
public ObservableCollection<TransactionViewModel> Transactions
{
get { return _transactions; }

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/ReceiveTabViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/ReceiveTabViewModel.cs
@@ -5,6 +5,7 @@ using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
+using System.Reactive.Linq;
using System.Text;
using System.Threading.Tasks;
using WalletWasabi.Gui.ViewModels;
@@ -25,7 +26,12 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
{
_addresses = new ObservableCollection<AddressViewModel>();
- Global.WalletService.Coins.CollectionChanged += Coins_CollectionChanged;
+ Observable.FromEventPattern(Global.WalletService.Coins, nameof(Global.WalletService.Coins.HashSetChanged))
+ .ObserveOn(RxApp.MainThreadScheduler)
+ .Subscribe(o =>
+ {
+ InitializeAddresses();
+ });
InitializeAddresses();
@@ -65,11 +71,6 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
});
}
- private void Coins_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
- {
- Dispatcher.UIThread.InvokeAsync(() => InitializeAddresses());
- }
-
private void InitializeAddresses()
{
_addresses?.Clear();

use RxUI Scheduler for dispatching onto ui thread

to rebuild the lists to display on ui.