I'm currently using this library for the windows task scheduler https://github.com/dahall/TaskScheduler
What I want is to end the running task. In my research, I found that I can able to disable the task by this code snippet task.Definition.Settings.Enabled = false
. But I did not find any way to end the running task. Can anyone help me with this?
CodePudding user response:
Have you tried:
task.Stop();
https://dahall.github.io/TaskScheduler/html/M_Microsoft_Win32_TaskScheduler_Task_Stop.htm
You can retrieve all tasks using:
new TaskService().AllTasks
CodePudding user response:
I think, what you are looking is Task.Stop()
and RunningTask.Stop()
(inherited from Task
class) methods. Obviously, they stops the registered task immediately. As described in source code:
System account users can stop a task, users with Administrator group privileges can stop a task, and if a user has rights to execute and read a task, then the user can stop the task. A user can stop the task instances that are running under the same credentials as the user account. In all other cases, the user is denied access to stop the task.
Is that what you looking for?