Skip to content

Commit 89ef6a8

Browse files
authored
Code Quality: Moved CheckAppUpdate() to run in a separate thread (#17607)
1 parent ed76489 commit 89ef6a8

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/Files.App/Helpers/Application/AppLifecycleHelper.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,11 @@ await Task.WhenAll(
128128

129129
FileTagsHelper.UpdateTagsDb();
130130

131-
// Release notes tab doesn't open unless this is awaited
132-
// Auto update doesn't work unless this is awaited
133-
await CheckAppUpdate();
131+
_ = Task.Run(async () =>
132+
{
133+
// The follwing method invokes UI thread, so we run it in a separate task
134+
await CheckAppUpdate();
135+
});
134136

135137
static Task OptionalTaskAsync(Task task, bool condition)
136138
{
@@ -158,8 +160,11 @@ public static async Task CheckAppUpdate()
158160
updateService.AreReleaseNotesAvailable &&
159161
!ViewedReleaseNotes)
160162
{
161-
await Ioc.Default.GetRequiredService<ICommandManager>().OpenReleaseNotes.ExecuteAsync();
162-
ViewedReleaseNotes = true;
163+
await MainWindow.Instance.DispatcherQueue.EnqueueOrInvokeAsync(async () =>
164+
{
165+
await Ioc.Default.GetRequiredService<ICommandManager>().OpenReleaseNotes.ExecuteAsync();
166+
ViewedReleaseNotes = true;
167+
});
163168
}
164169

165170
await updateService.CheckForUpdatesAsync();

0 commit comments

Comments
 (0)