public Progress(BasicAmbientProgress progressService, IAmbientProgress?parentProgress, float startPortion, float portionPart, string?prefix = null, bool inheritCancellationSource = true) { _tracker = progressService; _prefix = prefix ?? ""; _currentItem = ""; if (startPortion < 0.0 || startPortion > 1.0) { throw new ArgumentOutOfRangeException(nameof(startPortion), "The start portion must be between 0.0 and 1.0, inclusive!"); } if (portionPart < 0.0 || portionPart > 1.0) { throw new ArgumentOutOfRangeException(nameof(portionPart), "The portion part must be between 0.0 and 1.0, inclusive!"); } if (startPortion + portionPart > 1.0) { throw new ArgumentOutOfRangeException(nameof(portionPart), "The sum of the start portion and portion part must be 1.0 or less!"); } _parentProgress = parentProgress; _startPortion = startPortion; _portionPart = portionPart; if (_inheritedCancelSource = inheritCancellationSource) // note that this is an ASSIGNMENT in addition to a test { _cancelSource = parentProgress?.CancellationTokenSource ?? new AmbientCancellationTokenSource(); } else { _cancelSource = new AmbientCancellationTokenSource(); } progressService.PushSubProgress(this); }
public Progress(BasicAmbientProgress progress) : this(progress, null, 0.0f, 1.0f, null, false) { }