Class ProgressMonitor
- Namespace
- VpnHood.Net.Toolkit.Monitoring
- Assembly
- VpnHood.Net.Toolkit.dll
Provides the progress of a run of tasks as a percentage that also moves with time, so it does not stall while a batch of slow tasks runs: the larger of the share of tasks completed and the share of the time the batches may take.
public class ProgressMonitor
- Inheritance
-
ProgressMonitor
- Inherited Members
Remarks
A run of no tasks is complete, at 100. A task timeout that is not positive leaves the time out, and the percentage follows the completed tasks alone. In a release build the percentage stays within 0 to 100.
Constructors
ProgressMonitor(int, TimeSpan, int)
Provides the progress of a run of tasks as a percentage that also moves with time, so it does not stall while a batch of slow tasks runs: the larger of the share of tasks completed and the share of the time the batches may take.
public ProgressMonitor(int totalTaskCount, TimeSpan taskTimeout, int maxDegreeOfParallelism = 1)
Parameters
totalTaskCountintThe number of tasks.
taskTimeoutTimeSpanHow long one task may take; a batch may take as long.
maxDegreeOfParallelismintHow many tasks run at once, as a batch. The default is 1.
Remarks
A run of no tasks is complete, at 100. A task timeout that is not positive leaves the time out, and the percentage follows the completed tasks alone. In a release build the percentage stays within 0 to 100.
Exceptions
- ArgumentOutOfRangeException
totalTaskCountis negative, ormaxDegreeOfParallelismis less than 1.
Properties
Progress
Gets the progress now.
public ProgressStatus Progress { get; }
Property Value
Exceptions
- ArgumentOutOfRangeException
totalTaskCountis negative, ormaxDegreeOfParallelismis less than 1.
Methods
Finish()
Counts every task as completed.
public void Finish()
Exceptions
- ArgumentOutOfRangeException
totalTaskCountis negative, ormaxDegreeOfParallelismis less than 1.
IncrementCompleted()
Counts a completed task.
public void IncrementCompleted()
Exceptions
- ArgumentOutOfRangeException
totalTaskCountis negative, ormaxDegreeOfParallelismis less than 1.