コード例 #1
0
        /// <summary>
        /// Asks the user if they want to cancle the file fetcher process.
        /// </summary>
        /// <param name="fileFetcher"></param>
        /// <returns></returns>
        public bool cancleFileFetcher(UpdateRoutine fileFetcher)
        {
            var consoleKey = Console.ReadKey(true);

                if (consoleKey.Key == ConsoleKey.Escape)
                {
                    fileFetcher.Pause();
                    UserInterface.WriteToConsole("\n\nDo you want to stop the current process? \nType s to stop or c to continue.");
                    string input = UserInterface.ReadFromConsole();
                    if (input.ToUpper() == "C")
                    {
                        fileFetcher.Resume();
                        return false; // Continue
                    }
                    else if (input.ToUpper() == "S")
                    {
                        return true; // Break the loop
                    }
                    else
                    {
                        UserInterface.WriteToConsole("Error: Input was not recognized, the current process will now continue. Press Esc to stop the operation.");
                    }
                }
            return false;
        }