stop countdown on unload

This commit is contained in:
bluepilledgreat 2024-10-29 20:44:14 +00:00
parent 81baca5ffa
commit e9712d1730
3 changed files with 13 additions and 1 deletions

View File

@ -10,6 +10,7 @@
d:DesignHeight="450" d:DesignWidth="800"
Scrollable="True"
Loaded="Page_Loaded"
Unloaded="Page_Unloaded"
Title="FastFlagEditorWarningPage">
<StackPanel VerticalAlignment="Center">

View File

@ -31,5 +31,10 @@ namespace Bloxstrap.UI.Elements.Settings.Pages
((FastFlagEditorWarningViewModel)DataContext).StartCountdown();
}
private void Page_Unloaded(object sender, RoutedEventArgs e)
{
((FastFlagEditorWarningViewModel)DataContext).StopCountdown();
}
}
}

View File

@ -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);