From f1ec592834961617bee42282a17bbfec25a49fc8 Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Sun, 10 Jul 2011 22:05:52 -0700 Subject: [PATCH] Priority is now set using a timer --- NzbDrone/Program.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/NzbDrone/Program.cs b/NzbDrone/Program.cs index 25a16fd74..0eea8feef 100644 --- a/NzbDrone/Program.cs +++ b/NzbDrone/Program.cs @@ -1,9 +1,9 @@ using System; using System.Diagnostics; using System.Threading; +using System.Timers; using Exceptioneer.WindowsFormsClient; using NLog; - namespace NzbDrone { internal static class Program @@ -20,7 +20,9 @@ namespace NzbDrone Process currentProcess = Process.GetCurrentProcess(); - FixPriorities(); + var prioCheckTimer = new System.Timers.Timer(5000); + prioCheckTimer.Elapsed += prioCheckTimer_Elapsed; + prioCheckTimer.Enabled = true; currentProcess.EnableRaisingEvents = true; currentProcess.Exited += ProgramExited; @@ -35,7 +37,6 @@ namespace NzbDrone #if DEBUG Attach(); #endif - FixPriorities(); if (Environment.UserInteractive) { @@ -63,7 +64,7 @@ namespace NzbDrone Console.ReadLine(); } - private static void FixPriorities() + static void prioCheckTimer_Elapsed(object sender, ElapsedEventArgs e) { Process currentProcess = Process.GetCurrentProcess(); if (currentProcess.PriorityClass < ProcessPriorityClass.Normal) @@ -73,8 +74,8 @@ namespace NzbDrone currentProcess.PriorityClass = ProcessPriorityClass.Normal; } - - if (IISController.IISProcess!=null && IISController.IISProcess.PriorityClass < ProcessPriorityClass.Normal) + + if (IISController.IISProcess != null && IISController.IISProcess.PriorityClass < ProcessPriorityClass.Normal) { Logger.Info("Promoting IISExpress process priority from {0} to {1}", IISController.IISProcess.PriorityClass, ProcessPriorityClass.Normal); @@ -82,6 +83,8 @@ namespace NzbDrone } } + + #if DEBUG private static void Attach() {