Skip to content

Commit

Permalink
Startup re-scheduling #1410
Browse files Browse the repository at this point in the history
  • Loading branch information
seerge committed Oct 3, 2023
1 parent 46bfda3 commit 2d7009d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/GHelper.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<PlatformTarget>AnyCPU</PlatformTarget>
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<AssemblyVersion>0.127</AssemblyVersion>
<AssemblyVersion>0.128</AssemblyVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand Down
24 changes: 22 additions & 2 deletions app/Helpers/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ public class Startup

public static bool IsScheduled()
{
TaskService taskService = new TaskService();
return (taskService.RootFolder.AllTasks.Any(t => t.Name == taskName));
using (TaskService taskService = new TaskService())
return (taskService.RootFolder.AllTasks.Any(t => t.Name == taskName));
}

public static void ReScheduleAdmin()
Expand All @@ -23,6 +23,26 @@ public static void ReScheduleAdmin()
}
}

public static void StartupCheck()
{
using (TaskService taskService = new TaskService())
{
var task = taskService.RootFolder.AllTasks.FirstOrDefault(t => t.Name == taskName);
if (task != null)
{
string strExeFilePath = Application.ExecutablePath.Trim();
string action = task.Definition.Actions.FirstOrDefault()!.ToString().Trim();
if (!strExeFilePath.Equals(action, StringComparison.OrdinalIgnoreCase))
{
Logger.WriteLine(action);
Logger.WriteLine("Rescheduling to: " + strExeFilePath);
UnSchedule();
Schedule();
}
}
}
}

public static void Schedule()
{

Expand Down
3 changes: 3 additions & 0 deletions app/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,9 @@ public static void SettingsToggle(string action = "", bool checkForFocus = true)
settingsForm.FansToggle(2);
modeControl.SetRyzen();
break;
default:
Startup.StartupCheck();
break;
}
}
}
Expand Down

0 comments on commit 2d7009d

Please sign in to comment.