#333, reduce waiting PW to exit period from 10 second2 to 2 seconds

This commit is contained in:
Kang Yu 2024-06-29 18:22:37 -07:00
parent aca54b9ec1
commit a94ebd44f9

View file

@ -322,7 +322,7 @@ namespace PersistentWindows.SystrayShell
if (relaunch) if (relaunch)
{ {
Restart(); Restart(2);
return; return;
} }
@ -401,14 +401,14 @@ namespace PersistentWindows.SystrayShell
Log.Error("taskbar not ready, restart PersistentWindows"); Log.Error("taskbar not ready, restart PersistentWindows");
} }
Restart(); Restart(10);
return false; return false;
} }
static void Restart() static void Restart(int delay)
{ {
string batFile = Path.Combine(AppdataFolder, $"pw_restart.bat"); string batFile = Path.Combine(AppdataFolder, $"pw_restart.bat");
string content = "timeout /t 10 /nobreak > NUL"; string content = $"timeout /t {delay} /nobreak > NUL";
content += "\nstart \"\" /B \"" + Path.Combine(Application.StartupPath, Application.ProductName) + ".exe\" " + "-wait_taskbar " + Program.CmdArgs; content += "\nstart \"\" /B \"" + Path.Combine(Application.StartupPath, Application.ProductName) + ".exe\" " + "-wait_taskbar " + Program.CmdArgs;
File.WriteAllText(batFile, content); File.WriteAllText(batFile, content);
Process.Start(batFile); Process.Start(batFile);