Ejemplo n.º 1
0
 public static void CheckAndBoost(bool noClient)
 {
     logger.Debug("Checking processes for changing priority. No Client Arg: " + noClient);
     if (Process.GetProcessesByName(Strings.ClientProcessNames[0]).Length != 0)
     {
         Boost(true);
     }
     else
     {
         if (noClient)
         {
             Boost(!noClient); // client running false
         }
         else if (Process.GetProcessesByName(Strings.GameProcessName).Length != 0)
         {
             logger.Info("Game has been started. Process name: " + Strings.GameProcessName);
             logger.Info("Game was not boosted because client is not running. Checked process name: " + Strings.ClientProcessNames[0]);
             GameBoostFail?.Invoke(null, new LeagueBoostErrorEventArgs(false, new Exception("Client is not running."), "Game was not boosted because client is not running."));
         }
     }
 }
Ejemplo n.º 2
0
 private static void Boost(bool clientRunning)
 {
     try
     {
         if (Process.GetProcessesByName(Strings.GameProcessName).Length != 0)
         {
             logger.Debug("Trying to boost game. Client running: " + clientRunning);
             if (clientRunning)
             {
                 if (!IsGameHigh() || !IsClientBelowNormal())
                 {
                     try
                     {
                         SetClientPriority(ProcessPriorityClass.BelowNormal);
                         SetGamePriority(ProcessPriorityClass.High);
                         logger.Info("Game has been boosted successfully.");
                         GameBoostOk?.Invoke(null, new LeagueBoostEventArgs(clientRunning));
                     }
                     catch (Exception ex)
                     {
                         logger.Error(ex, Strings.exceptionThrown + " while boosting game: " + Environment.NewLine);
                         GameBoostFail?.Invoke(null, new LeagueBoostErrorEventArgs(clientRunning, ex));
                     }
                 }
             }
             else if (!IsGameHigh())
             {
                 try
                 {
                     SetGamePriority(ProcessPriorityClass.High);
                     logger.Info("Game has been boosted successfully.");
                     GameBoostOk?.Invoke(null, new LeagueBoostEventArgs(clientRunning));
                 }
                 catch (Exception ex)
                 {
                     logger.Error(ex, Strings.exceptionThrown + " while boosting game: " + Environment.NewLine);
                     GameBoostFail?.Invoke(null, new LeagueBoostErrorEventArgs(clientRunning, ex));
                 }
             }
         }
         else if (clientRunning && !IsClientNormal())
         {
             try
             {
                 SetClientPriority(ProcessPriorityClass.Normal);
                 logger.Info("Client has been returned to normal successfully.");
                 ClientNormalOk?.Invoke(null, new LeagueBoostEventArgs(clientRunning));
             }
             catch (Exception ex)
             {
                 logger.Error(ex, Strings.exceptionThrown + " while returning client to normal: " + Environment.NewLine);
                 ClientNormalFail?.Invoke(null, new LeagueBoostErrorEventArgs(clientRunning, ex));
             }
         }
         else
         {
             logger.Debug("Game is not running.");
         }
     }
     catch (Exception ex)
     {
         logger.Error(ex, Strings.exceptionThrown + " while trying to boost game." + Environment.NewLine);
     }
 }