dispose cancellation token source in cannot close dialog.
MODIFY
WalletWasabi.Dependencies/AvalonStudio.Shell
WalletWasabi.Dependencies/AvalonStudio.Shell
-Subproject commit f0be563e8474eadd0cbb0ebebe72a75ff5db2dae
+Subproject commit 4aa379359fd73c3d8a00de30d069787dbf2163b1

MODIFY
WalletWasabi.Gui/Dialogs/CannotCloseDialogViewModel.cs
WalletWasabi.Gui/Dialogs/CannotCloseDialogViewModel.cs
@@ -3,6 +3,7 @@ using AvalonStudio.Extensibility.Dialogs;
using ReactiveUI;
using System;
using System.Linq;
+using System.Reactive.Disposables;
using System.Threading;
using System.Threading.Tasks;
using WalletWasabi.Models;
@@ -15,7 +16,9 @@ namespace WalletWasabi.Gui.Dialogs
private string _warningMessage;
private string _operationMessage;
- private CancellationTokenSource CancelTokenSource { get; }
+ private CompositeDisposable Disposables { get; set; }
+
+ private CancellationTokenSource CancelTokenSource { get; set; }
public bool IsBusy
{
@@ -47,8 +50,6 @@ namespace WalletWasabi.Gui.Dialogs
var canCancel = this.WhenAnyValue(x => x.IsBusy);
var canOk = this.WhenAnyValue(x => x.IsBusy, (isbusy) => !isbusy);
- CancelTokenSource = new CancellationTokenSource();
-
OKCommand = ReactiveCommand.CreateFromTask(async () =>
{
CancelTokenSource.Cancel();
@@ -76,8 +77,29 @@ namespace WalletWasabi.Gui.Dialogs
OKCommand.ThrownExceptions.Subscribe(ex => Logging.Logger.LogWarning<CannotCloseDialogViewModel>(ex));
CancelCommand.ThrownExceptions.Subscribe(ex => Logging.Logger.LogWarning<CannotCloseDialogViewModel>(ex));
+ }
+
+ public override void OnOpen()
+ {
+ if(Disposables != null)
+ {
+ throw new Exception("Dialog opened before it was closed (cannotclose)");
+ }
+
+ Disposables = new CompositeDisposable();
+
+ CancelTokenSource = new CancellationTokenSource().DisposeWith(Disposables);
Initialization = StartDequeueAsync(CancelTokenSource.Token);
+
+ base.OnOpen();
+ }
+
+ public override void OnClose()
+ {
+ Disposables.Dispose();
+ Disposables = null;
+ base.OnClose();
}
private async Task StartDequeueAsync(CancellationToken token)

dispose cancellation token source in cannot close dialog.