From 4b056c19aef7881dd8f8a13f4f36f20d3bee5dfc Mon Sep 17 00:00:00 2001 From: Kristen Schau <47155823+krschau@users.noreply.github.com> Date: Tue, 20 Aug 2024 16:00:14 -0400 Subject: [PATCH 1/2] Initialize initWidgetsCancellationTokenSource in constructor --- .../Dashboard/DevHome.Dashboard/Views/DashboardView.xaml.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/Dashboard/DevHome.Dashboard/Views/DashboardView.xaml.cs b/tools/Dashboard/DevHome.Dashboard/Views/DashboardView.xaml.cs index 9a5662f479..06995c5749 100644 --- a/tools/Dashboard/DevHome.Dashboard/Views/DashboardView.xaml.cs +++ b/tools/Dashboard/DevHome.Dashboard/Views/DashboardView.xaml.cs @@ -52,7 +52,7 @@ public partial class DashboardView : ToolPage, IDisposable private static DispatcherQueue _dispatcherQueue; private readonly ILocalSettingsService _localSettingsService; private readonly IWidgetExtensionService _widgetExtensionService; - private CancellationTokenSource _initWidgetsCancellationTokenSource; + private readonly CancellationTokenSource _initWidgetsCancellationTokenSource; private bool _disposedValue; private const string DraggedWidget = "DraggedWidget"; @@ -68,6 +68,8 @@ public DashboardView() ViewModel.PinnedWidgets.CollectionChanged += OnPinnedWidgetsCollectionChangedAsync; + _initWidgetsCancellationTokenSource = new(); + _dispatcherQueue = Application.Current.GetService(); _localSettingsService = Application.Current.GetService(); _widgetExtensionService = Application.Current.GetService(); @@ -206,7 +208,6 @@ private async Task InitializeDashboard() await _localSettingsService.SaveSettingAsync(WellKnownSettingsKeys.IsNotFirstDashboardRun, true); } - _initWidgetsCancellationTokenSource = new(); try { await InitializePinnedWidgetListAsync(isFirstDashboardRun, _initWidgetsCancellationTokenSource.Token); From 883e0291ea2521491d9ab75ce3ea02652c87bd1f Mon Sep 17 00:00:00 2001 From: Kristen Schau <47155823+krschau@users.noreply.github.com> Date: Tue, 20 Aug 2024 16:29:11 -0400 Subject: [PATCH 2/2] simplify initialization --- tools/Dashboard/DevHome.Dashboard/Views/DashboardView.xaml.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tools/Dashboard/DevHome.Dashboard/Views/DashboardView.xaml.cs b/tools/Dashboard/DevHome.Dashboard/Views/DashboardView.xaml.cs index 06995c5749..63ad547c3e 100644 --- a/tools/Dashboard/DevHome.Dashboard/Views/DashboardView.xaml.cs +++ b/tools/Dashboard/DevHome.Dashboard/Views/DashboardView.xaml.cs @@ -52,7 +52,7 @@ public partial class DashboardView : ToolPage, IDisposable private static DispatcherQueue _dispatcherQueue; private readonly ILocalSettingsService _localSettingsService; private readonly IWidgetExtensionService _widgetExtensionService; - private readonly CancellationTokenSource _initWidgetsCancellationTokenSource; + private readonly CancellationTokenSource _initWidgetsCancellationTokenSource = new(); private bool _disposedValue; private const string DraggedWidget = "DraggedWidget"; @@ -68,8 +68,6 @@ public DashboardView() ViewModel.PinnedWidgets.CollectionChanged += OnPinnedWidgetsCollectionChangedAsync; - _initWidgetsCancellationTokenSource = new(); - _dispatcherQueue = Application.Current.GetService(); _localSettingsService = Application.Current.GetService(); _widgetExtensionService = Application.Current.GetService();