diff --git a/Bloxstrap/UI/Elements/Settings/Pages/FastFlagEditorWarningPage.xaml b/Bloxstrap/UI/Elements/Settings/Pages/FastFlagEditorWarningPage.xaml index 9a2b938..55b0d71 100644 --- a/Bloxstrap/UI/Elements/Settings/Pages/FastFlagEditorWarningPage.xaml +++ b/Bloxstrap/UI/Elements/Settings/Pages/FastFlagEditorWarningPage.xaml @@ -10,6 +10,7 @@ d:DesignHeight="450" d:DesignWidth="800" Scrollable="True" Loaded="Page_Loaded" + Unloaded="Page_Unloaded" Title="FastFlagEditorWarningPage"> diff --git a/Bloxstrap/UI/Elements/Settings/Pages/FastFlagEditorWarningPage.xaml.cs b/Bloxstrap/UI/Elements/Settings/Pages/FastFlagEditorWarningPage.xaml.cs index 8a8d723..6f35278 100644 --- a/Bloxstrap/UI/Elements/Settings/Pages/FastFlagEditorWarningPage.xaml.cs +++ b/Bloxstrap/UI/Elements/Settings/Pages/FastFlagEditorWarningPage.xaml.cs @@ -31,5 +31,10 @@ namespace Bloxstrap.UI.Elements.Settings.Pages ((FastFlagEditorWarningViewModel)DataContext).StartCountdown(); } + + private void Page_Unloaded(object sender, RoutedEventArgs e) + { + ((FastFlagEditorWarningViewModel)DataContext).StopCountdown(); + } } } diff --git a/Bloxstrap/UI/ViewModels/Settings/FastFlagEditorWarningViewModel.cs b/Bloxstrap/UI/ViewModels/Settings/FastFlagEditorWarningViewModel.cs index 08a18fe..957f62b 100644 --- a/Bloxstrap/UI/ViewModels/Settings/FastFlagEditorWarningViewModel.cs +++ b/Bloxstrap/UI/ViewModels/Settings/FastFlagEditorWarningViewModel.cs @@ -28,9 +28,15 @@ namespace Bloxstrap.UI.ViewModels.Settings _page = page; } - public void StartCountdown() + public void StopCountdown() { _cancellationTokenSource?.Cancel(); + _cancellationTokenSource = null; + } + + public void StartCountdown() + { + StopCountdown(); _cancellationTokenSource = new CancellationTokenSource(); DoCountdown(_cancellationTokenSource.Token);