-1

I'm trying to create a mechanic where, while my program is completing a task that may take a while, it prints a percentage of how much of the task is complete (e.g. 30% complete to 31% complete). I've got percentage calculation down, but not printing it. I assume I'll have to get the text that already exists on the screen to do that.

Windows 7
  • 1
  • 1
  • 1

1 Answers1

-1

Simple example of loading display. It has some flicker but I think that with a bit more spent time this could be fixed

class Program
    {
        static void Main()
        {
            for (int i = 0; i < 20; i++)
            {
                WriteMessage($"Some text, {i}");
                ShowPercentage(i);
                Thread.Sleep(100);
            }

            Console.CursorTop = Console.WindowHeight - 2;
            Console.Write("                        ");
            Console.CursorLeft = 0;
            Console.WriteLine("Done");
        }

        static void WriteMessage(string msg)
        {
            Console.CursorTop = Console.WindowHeight - 2;
            Console.WriteLine(msg);
        }

        static void ShowPercentage(int value)
        {
            Console.CursorTop = Console.WindowHeight - 1;
            Console.WriteLine($"Loaded {value}%");
        }
    }
JL0PD
  • 3,698
  • 2
  • 15
  • 23