Exemplo n.º 1
0
        public void Reset()
        {
            _state = ProgressSampleState.Stopped;

            ProgressSampleUnit result;

            while (_samples.TryDequeue(out result))
            {
            }
        }
Exemplo n.º 2
0
        public void Resume(double percentComplete)
        {
            if (_state != ProgressSampleState.Paused)
            {
                throw new InvalidOperationException(
                          string.Format("Unable to Resume: must be in {0} state, but instead found {1} state",
                                        ProgressSampleState.Paused, _state));
            }

            Enqueue(percentComplete, TimeSpan.Zero);

            _state = ProgressSampleState.Running;
        }
Exemplo n.º 3
0
        public void Pause()
        {
            if (_state != ProgressSampleState.Running)
            {
                throw new InvalidOperationException(
                          string.Format("Unable to Pause: must be in {0} state, but instead found {1} state",
                                        ProgressSampleState.Running, _state));
            }

            Add(LastSamplePercent);

            _state = ProgressSampleState.Paused;
        }
Exemplo n.º 4
0
        /// <summary>
        ///     Adds a sample to the queue and recalculates the estimated time remaining.
        /// </summary>
        /// <param name="percentComplete">From 0.0 to 100.0.</param>
        public void Add(double percentComplete)
        {
            if (_state == ProgressSampleState.Paused)
            {
                Resume(percentComplete);
            }

            _state = ProgressSampleState.Running;

            var duration       = TimeSpan.Zero;
            var lastSampleTime = LastSampleTime;

            if (lastSampleTime.HasValue)
            {
                duration = DateTime.Now - lastSampleTime.Value;
            }

            Enqueue(percentComplete, duration);
        }
Exemplo n.º 5
0
 public void Stop()
 {
     _state = ProgressSampleState.Stopped;
 }
Exemplo n.º 6
0
        public void Reset()
        {
            _state = ProgressSampleState.Stopped;

            ProgressSampleUnit result;
            while (_samples.TryDequeue(out result))
            {
            }
        }
Exemplo n.º 7
0
 public void Stop()
 {
     _state = ProgressSampleState.Stopped;
 }
Exemplo n.º 8
0
        public void Resume(double percentComplete)
        {
            if (_state != ProgressSampleState.Paused)
            {
                throw new InvalidOperationException(
                    string.Format("Unable to Resume: must be in {0} state, but instead found {1} state",
                                  ProgressSampleState.Paused, _state));
            }

            Enqueue(percentComplete, TimeSpan.Zero);

            _state = ProgressSampleState.Running;
        }
Exemplo n.º 9
0
        public void Pause()
        {
            if (_state != ProgressSampleState.Running)
            {
                throw new InvalidOperationException(
                    string.Format("Unable to Pause: must be in {0} state, but instead found {1} state",
                                  ProgressSampleState.Running, _state));
            }

            Add(LastSamplePercent);

            _state = ProgressSampleState.Paused;
        }
Exemplo n.º 10
0
        /// <summary>
        ///     Adds a sample to the queue and recalculates the estimated time remaining.
        /// </summary>
        /// <param name="percentComplete">From 0.0 to 100.0.</param>
        public void Add(double percentComplete)
        {
            if (_state == ProgressSampleState.Paused)
            {
                Resume(percentComplete);
            }

            _state = ProgressSampleState.Running;

            var duration = TimeSpan.Zero;
            var lastSampleTime = LastSampleTime;

            if (lastSampleTime.HasValue)
            {
                duration = DateTime.Now - lastSampleTime.Value;
            }

            Enqueue(percentComplete, duration);
        }