restore process priority 10 seconds after startup

This commit is contained in:
Kang Yu 2025-05-03 17:24:44 -07:00
parent 4df563f1bb
commit cad1ec393f
2 changed files with 10 additions and 12 deletions

View file

@ -161,7 +161,7 @@ namespace PersistentWindows.Common
private static Dictionary<IntPtr, string> windowProcessName = new Dictionary<IntPtr, string>(); private static Dictionary<IntPtr, string> windowProcessName = new Dictionary<IntPtr, string>();
private Process process; private Process process;
private ProcessPriorityClass processPriority; public ProcessPriorityClass processPriority;
private string appDataFolder; private string appDataFolder;
public bool redirectAppDataFolder = false; public bool redirectAppDataFolder = false;
@ -594,8 +594,6 @@ namespace PersistentWindows.Common
public bool Start(bool auto_restore_from_db, bool auto_restore_last_capture_at_startup) public bool Start(bool auto_restore_from_db, bool auto_restore_last_capture_at_startup)
{ {
process = Process.GetCurrentProcess(); process = Process.GetCurrentProcess();
processPriority = process.PriorityClass;
string productName = System.Windows.Forms.Application.ProductName; string productName = System.Windows.Forms.Application.ProductName;
appDataFolder = redirectAppDataFolder ? "." : appDataFolder = redirectAppDataFolder ? "." :
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), productName); Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), productName);

View file

@ -48,15 +48,6 @@ if not errorlevel 1 goto wait_to_finish";
[STAThread] [STAThread]
static void Main(string[] args) static void Main(string[] args)
{ {
var process = Process.GetCurrentProcess();
var process_priority = process.PriorityClass;
process.PriorityClass = ProcessPriorityClass.High;
var timer = new System.Threading.Timer(state =>
{
process.PriorityClass = process_priority;
});
timer.Change(10000, System.Threading.Timeout.Infinite);
Application.EnableVisualStyles(); Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false); Application.SetCompatibleTextRenderingDefault(false);
@ -65,6 +56,15 @@ if not errorlevel 1 goto wait_to_finish";
pwp = new PersistentWindowProcessor(); pwp = new PersistentWindowProcessor();
var process = Process.GetCurrentProcess();
pwp.processPriority = process.PriorityClass;
process.PriorityClass = ProcessPriorityClass.High;
var timer = new System.Threading.Timer(state =>
{
process.PriorityClass = pwp.processPriority;
});
timer.Change(10000, System.Threading.Timeout.Infinite);
bool splash = true; bool splash = true;
int delay_restart = 0; int delay_restart = 0;
int relaunch_delay = 0; int relaunch_delay = 0;