Priority is now set using a timer
This commit is contained in:
parent
d640fa65e8
commit
f1ec592834
|
@ -1,9 +1,9 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
using System.Timers;
|
||||||
using Exceptioneer.WindowsFormsClient;
|
using Exceptioneer.WindowsFormsClient;
|
||||||
using NLog;
|
using NLog;
|
||||||
|
|
||||||
namespace NzbDrone
|
namespace NzbDrone
|
||||||
{
|
{
|
||||||
internal static class Program
|
internal static class Program
|
||||||
|
@ -20,7 +20,9 @@ namespace NzbDrone
|
||||||
|
|
||||||
Process currentProcess = Process.GetCurrentProcess();
|
Process currentProcess = Process.GetCurrentProcess();
|
||||||
|
|
||||||
FixPriorities();
|
var prioCheckTimer = new System.Timers.Timer(5000);
|
||||||
|
prioCheckTimer.Elapsed += prioCheckTimer_Elapsed;
|
||||||
|
prioCheckTimer.Enabled = true;
|
||||||
|
|
||||||
currentProcess.EnableRaisingEvents = true;
|
currentProcess.EnableRaisingEvents = true;
|
||||||
currentProcess.Exited += ProgramExited;
|
currentProcess.Exited += ProgramExited;
|
||||||
|
@ -35,7 +37,6 @@ namespace NzbDrone
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
Attach();
|
Attach();
|
||||||
#endif
|
#endif
|
||||||
FixPriorities();
|
|
||||||
|
|
||||||
if (Environment.UserInteractive)
|
if (Environment.UserInteractive)
|
||||||
{
|
{
|
||||||
|
@ -63,7 +64,7 @@ namespace NzbDrone
|
||||||
Console.ReadLine();
|
Console.ReadLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void FixPriorities()
|
static void prioCheckTimer_Elapsed(object sender, ElapsedEventArgs e)
|
||||||
{
|
{
|
||||||
Process currentProcess = Process.GetCurrentProcess();
|
Process currentProcess = Process.GetCurrentProcess();
|
||||||
if (currentProcess.PriorityClass < ProcessPriorityClass.Normal)
|
if (currentProcess.PriorityClass < ProcessPriorityClass.Normal)
|
||||||
|
@ -74,7 +75,7 @@ namespace NzbDrone
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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,
|
Logger.Info("Promoting IISExpress process priority from {0} to {1}", IISController.IISProcess.PriorityClass,
|
||||||
ProcessPriorityClass.Normal);
|
ProcessPriorityClass.Normal);
|
||||||
|
@ -82,6 +83,8 @@ namespace NzbDrone
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
private static void Attach()
|
private static void Attach()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue