Mpdreamz / shellprogressbar

ShellProgressBar - display progress in your console application
MIT License
1.43k stars 134 forks source link

WriteLine not work with .net Framework #50

Open hepter opened 4 years ago

hepter commented 4 years ago

I'm using with .Net framework .Nothing appears except the first line. I changed some of code parts , but console still not showing like the .net core example image

budul100 commented 3 years ago

The problem is apparently caused in the WriteConsoleLine function. On certain circumstances, the rolling back of the cursor with Console.Write("\r") is not working correctly.

If you replace the current code by the following code, then it should work in the .NET framework, too:

private void WriteConsoleLine(ConsoleOutLine m)
{
    var resetString = new string(' ', Console.WindowWidth);

    var line = Console.CursorTop;
    Console.Write(resetString);
    Console.SetCursorPosition(0, line);

    var foreground = Console.ForegroundColor;
    var background = Console.BackgroundColor;
    var written = _writeMessageToConsole(m);
    Console.ForegroundColor = foreground;
    Console.BackgroundColor = background;
    _originalCursorTop += written;
}
yellowz06 commented 6 months ago

I am having the same issue, will this be fixed in future release?