diff --git a/src/Files.App/App.xaml.cs b/src/Files.App/App.xaml.cs index 5cd7d8b7a546..0ca6dcc706c1 100644 --- a/src/Files.App/App.xaml.cs +++ b/src/Files.App/App.xaml.cs @@ -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(); } } diff --git a/src/Files.App/Helpers/Application/AppLifecycleHelper.cs b/src/Files.App/Helpers/Application/AppLifecycleHelper.cs index 07062522a299..3ca342a3d309 100644 --- a/src/Files.App/Helpers/Application/AppLifecycleHelper.cs +++ b/src/Files.App/Helpers/Application/AppLifecycleHelper.cs @@ -52,6 +52,8 @@ await Task.WhenAll( FileTagsHelper.UpdateTagsDb(); + await CheckAppUpdate(); + static Task OptionalTaskAsync(Task task, bool condition) { if (condition)