6

I'm using the C# Task Scheduler Library to manage tasks: https://github.com/dahall/TaskScheduler

On a given task, I can set the "Enabled" boolean and persist the changes:

  task.Enabled= true;
  task.State.Dump();
  task.RegisterChanges();

But the call to RegisterChanges() does not result in a change. Am I missing something? Is there some other way to disable a task using this library?

Am_I_Helpful
  • 18,735
  • 7
  • 49
  • 73
Daniel Williams
  • 8,912
  • 15
  • 68
  • 107
  • Without further relevant code, it's hard to tell, but going by the simple example on the GitHub portal, it doesn't look like you're even close to using it correctly. Also, if you're trying to disable the task, why are you setting `Enabled = true;`, instead of `false`? – Mark Benningfield Feb 21 '18 at 17:35

1 Answers1

7

Found it. The property to set is not the one on the task itself, but rather in the Definition Settings:

task.Definition.Settings.Enabled = true;

Open source on github is so helpful!

Daniel Williams
  • 8,912
  • 15
  • 68
  • 107