diff --git a/CollapseLauncher/XAMLs/MainApp/Pages/HomePage.xaml.cs b/CollapseLauncher/XAMLs/MainApp/Pages/HomePage.xaml.cs index 5a5bef6fa..df94f13a5 100644 --- a/CollapseLauncher/XAMLs/MainApp/Pages/HomePage.xaml.cs +++ b/CollapseLauncher/XAMLs/MainApp/Pages/HomePage.xaml.cs @@ -63,7 +63,7 @@ public sealed partial class HomePage { #region Properties private GamePresetProperty CurrentGameProperty { get; set; } - private CancellationTokenSource PageToken { get; set; } + private CancellationTokenSourceWrapper PageToken { get; set; } private CancellationTokenSourceWrapper CarouselToken { get; set; } private int barWidth; @@ -145,7 +145,7 @@ private async void StartLoadedRoutine(object sender, RoutedEventArgs e) // HACK: Fix random crash by manually load the XAML part // But first, let it initialize its properties. CurrentGameProperty = GamePropertyVault.GetCurrentGameProperty(); - PageToken = new CancellationTokenSource(); + PageToken = new CancellationTokenSourceWrapper(); CarouselToken = new CancellationTokenSourceWrapper(); this.InitializeComponent(); @@ -247,8 +247,8 @@ private async void StartLoadedRoutine(object sender, RoutedEventArgs e) private void Page_Unloaded(object sender, RoutedEventArgs e) { IsPageUnload = true; - PageToken.Cancel(); - CarouselToken.Cancel(); + if (!PageToken.IsCancelled) PageToken.Cancel(); + if (!CarouselToken.IsCancelled) CarouselToken.Cancel(); } #endregion