Mpdreamz / shellprogressbar

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

Crashes in Ubuntu 16.04 #23

Closed buhbuhtig closed 4 years ago

buhbuhtig commented 6 years ago
  1. Compiled under Windows: using (var pg = new ProgressBar(100, "Lalala")) { for (int i = 0; i < 10; i++) { Thread.Sleep(500); //pg.Tick(); <-commented } } ` dotnet --version 2.1.104

  2. Published for Ubuntu 16.04 under Windows: dotnet publish -c release -r ubuntu.16.04-x64

  3. Copied to Ubuntu 16.04

  4. Exception thrown by application running in Ubuntu 16.04:

Unhandled Exception: System.ArgumentOutOfRangeException: Length cannot be less than zero. Parameter name: length at System.String.Substring(Int32 startIndex, Int32 length) at ShellProgressBar.StringExtensions.Excerpt(String phrase, Int32 length) at ShellProgressBar.ProgressBar.ProgressBarBottomHalf(Double percentage, DateTime startDate, Nullable`1 endDate, String message, Indentation[] indentation, Boolean progressBarOnBottom) at ShellProgressBar.ProgressBar.DisplayProgress() at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.TimerQueueTimer.CallCallback() at System.Threading.TimerQueueTimer.Fire() at System.Threading.TimerQueue.FireNextTimers()

paulgmiller commented 6 years ago

Yeah so Console.WindowWidth can be zero apparent;y I hit this in a continuoous integration environment. Not clear what it should do when that happens.

dlech commented 5 years ago

Your program should test for Console.IsInputRedirected || Console.IsOutputRedirected. If this is true, the progress bar won't work, so it should not be used.

Mpdreamz commented 4 years ago

Since https://github.com/Mpdreamz/shellprogressbar/pull/44 went in I am going to close this issue.

Thanks everyone for reporting this, will dive in again if this remains an issue.