Added force shutdown functionality and option to select wether we want to force or not
This commit is contained in:
parent
c8654dbb85
commit
58fef5c307
@ -90,7 +90,14 @@ public static class Tranga_Cli
|
||||
break;
|
||||
}
|
||||
}
|
||||
taskManager.Shutdown();
|
||||
|
||||
if (taskManager.GetAllTasks().Any(task => task.isBeingExecuted))
|
||||
{
|
||||
Console.WriteLine("Force quit (Even with running tasks?) y/N");
|
||||
selection = Console.ReadKey().Key;
|
||||
taskManager.Shutdown(selection == ConsoleKey.Y);
|
||||
}else
|
||||
taskManager.Shutdown(false);
|
||||
}
|
||||
|
||||
private static ConsoleKey Menu(string folderPath)
|
||||
|
@ -85,10 +85,18 @@ public class TaskManager
|
||||
return this._chapterCollection.Keys.ToArray();
|
||||
}
|
||||
|
||||
public void Shutdown()
|
||||
public void Shutdown(bool force = false)
|
||||
{
|
||||
_continueRunning = false;
|
||||
ExportTasks(Directory.GetCurrentDirectory());
|
||||
|
||||
if(force)
|
||||
Environment.Exit(_allTasks.Count(task => task.isBeingExecuted));
|
||||
|
||||
//Wait for tasks to finish
|
||||
while(_allTasks.Any(task => task.isBeingExecuted))
|
||||
Thread.Sleep(10);
|
||||
|
||||
}
|
||||
|
||||
private HashSet<TrangaTask> ImportTasks(string importFolderPath)
|
||||
|
Loading…
Reference in New Issue
Block a user