internal ChildProgressBar(int maxTicks, string message, Action scheduleDraw, ProgressBarOptions options = null, Action<ProgressBarHeight> growth = null)
			: base(maxTicks, message, options)
		{
			_scheduleDraw = scheduleDraw;
			_growth = growth;
			_growth?.Invoke(ProgressBarHeight.Increment);
		}
 public ChildProgressBar Spawn(int maxTicks, string message, ProgressBarOptions options = null)
 {
     var pbar = new ChildProgressBar(maxTicks, message, DisplayProgress, options, this.Grow);
     this.Children.Add(pbar);
     DisplayProgress();
     return pbar;
 }
	    public ProgressBar(int maxTicks, string message, ProgressBarOptions options = null)
			: base(maxTicks, message, options)
        {
			_originalCursorTop = Console.CursorTop;
			_originalWindowTop = Console.WindowTop;
	        _originalColor = Console.ForegroundColor;

			Console.CursorVisible = false;

			if (this.Options.DisplayTimeInRealTime)
				_timer = new Timer((s) => DisplayProgress(), null, 500, 500);
        }
 protected ProgressBarBase(int maxTicks, string message, ProgressBarOptions options)
 {
     this._maxTicks = Math.Max(0, maxTicks);
     this._message = message;
     this.Options = options ?? ProgressBarOptions.Default;
 }
        public ProgressBar(int maxTicks, string message, ProgressBarOptions options = null)
            : base(maxTicks, message, options)
        {
            _writeMessageToConsole = this.Options.WriteQueuedMessage ?? DefaultConsoleWrite;
            _startedRedirected     = Console.IsOutputRedirected;

            try
            {
                _originalCursorTop    = Console.CursorTop;
                _originalWindowTop    = Console.WindowTop;
                _originalWindowHeight = Console.WindowHeight + _originalWindowTop;
                _originalColor        = Console.ForegroundColor;
            }
            catch
            {
                _startedRedirected = true;
            }

            if (!_startedRedirected)
            {
                Console.CursorVisible = false;
            }

            if (this.Options.EnableTaskBarProgress)
            {
                TaskbarProgress.SetState(TaskbarProgress.TaskbarStates.Normal);
            }

            if (this.Options.DisplayTimeInRealTime)
            {
                _timer = new Timer((s) => OnTimerTick(), null, 500, 500);
            }
            else             //draw once
            {
                _timer = new Timer((s) =>
                {
                    _timer.Dispose();
                    DisplayProgress();
                }, null, 0, 1000);
            }

            _displayProgressEvent = new AutoResetEvent(false);
            _displayProgress      = Task.Run(() =>
            {
                while (_isDisposed == 0)
                {
                    if (!_displayProgressEvent.WaitOne(TimeSpan.FromSeconds(10)))
                    {
                        continue;
                    }
                    if (_isDisposed > 0)
                    {
                        return;
                    }
                    try
                    {
                        UpdateProgress();
                    }
                    catch
                    {
                        //don't want to crash background thread
                    }
                }
            });
        }
 protected ProgressBarBase(int maxTicks, string message, ProgressBarOptions options)
 {
     this._maxTicks = Math.Max(0, maxTicks);
     this._message  = message;
     this.Options   = options ?? ProgressBarOptions.Default;
 }