public void Reset() { _state = ProgressSampleState.Stopped; ProgressSampleUnit result; while (_samples.TryDequeue(out result)) { } }
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; }
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; }
/// <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); }
public void Stop() { _state = ProgressSampleState.Stopped; }
public void Reset() { _state = ProgressSampleState.Stopped; ProgressSampleUnit result; while (_samples.TryDequeue(out result)) { } }
public void Stop() { _state = ProgressSampleState.Stopped; }
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; }
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; }
/// <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); }