Added option to immediately execute a task

This commit is contained in:
glax 2023-05-19 19:20:44 +02:00
parent 312672a05c
commit 133b3146b5
2 changed files with 19 additions and 0 deletions

View File

@ -61,6 +61,12 @@ public static class Tranga_Cli
Console.ReadKey();
menu = 0;
break;
case 4:
ExecuteTask(taskManager);
Console.WriteLine("Press any key.");
Console.ReadKey();
menu = 0;
break;
default:
selection = Menu(folderPath);
switch (selection)
@ -74,6 +80,9 @@ public static class Tranga_Cli
case ConsoleKey.D:
menu = 3;
break;
case ConsoleKey.E:
menu = 4;
break;
default:
menu = 0;
break;
@ -92,6 +101,7 @@ public static class Tranga_Cli
Console.WriteLine("L: List tasks");
Console.WriteLine("C: Create Task");
Console.WriteLine("D: Delete Task");
Console.WriteLine("E: Execute Task now");
Console.WriteLine("Q: Exit with saving");
ConsoleKey selection = Console.ReadKey().Key;
Console.WriteLine();

View File

@ -34,6 +34,15 @@ public class TaskManager
}
}
public void ExecuteTaskNow(TrangaTask task)
{
Task t = new Task(() =>
{
TaskExecutor.Execute(this.connectors, task, this._chapterCollection);
});
t.Start();
}
public void AddTask(TrangaTask.Task task, string connectorName, Publication? publication, TimeSpan reoccurrence,
string language = "")
{