Skip to content

Commit

Permalink
Code Quality: Faster background launch at Windows startup (files-comm…
Browse files Browse the repository at this point in the history
  • Loading branch information
hishitetsu authored Jan 15, 2024
1 parent 9368719 commit 6a3d1cc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
24 changes: 16 additions & 8 deletions src/Files.App/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,17 +135,25 @@ async Task ActivateAsync()

_ = MainWindow.Instance.InitializeApplicationAsync(appActivationArguments.Data);
}

await AppLifecycleHelper.InitializeAppComponentsAsync();

if (isStartupTask && isLeaveAppRunning)
else
{
// Create a system tray icon when initialization is done
// Create a system tray icon
SystemTrayIcon = new SystemTrayIcon().Show();
App.Current.Exit();

// Sleep current instance
Program.Pool = new(0, 1, $"Files-{ApplicationService.AppEnvironment}-Instance");

Thread.Yield();

if (Program.Pool.WaitOne())
{
// Resume the instance
Program.Pool.Dispose();
Program.Pool = null;
}
}
else
await AppLifecycleHelper.CheckAppUpdate();

await AppLifecycleHelper.InitializeAppComponentsAsync();
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/Files.App/Helpers/Application/AppLifecycleHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ await Task.WhenAll(

FileTagsHelper.UpdateTagsDb();

await CheckAppUpdate();

static Task OptionalTaskAsync(Task task, bool condition)
{
if (condition)
Expand Down

0 comments on commit 6a3d1cc

Please sign in to comment.