Class PercentageTask
A task that executes an Action<T> and reports progress in percent.
[CLSCompliant(false)]
public sealed class PercentageTask : TaskBase, ITask
- Inheritance
-
PercentageTask
- Implements
- Inherited Members
- Extension Methods
Constructors
PercentageTask(string, Action<PercentProgressCallback>, Action?)
A task that executes an Action<T> and reports progress in percent.
public PercentageTask(string name, Action<PercentProgressCallback> work, Action? cancellationCallback = null)
Parameters
name
stringA name describing the task in human-readable form.
work
Action<PercentProgressCallback>The code to be executed by the task. Is given a callback to report progress in percent. May throw WebException, IOException or OperationCanceledException.
cancellationCallback
ActionAn optional callback to be called when cancellation is requested via a CancellationToken.
Properties
CanCancel
Indicates whether this task can be canceled once it has been started.
public override bool CanCancel { get; }
Property Value
Name
A name describing the task in human-readable form.
public override string Name { get; }
Property Value
UnitsByte
true
if UnitsProcessed and UnitsTotal are measured in bytes;
false
if they are measured in generic units.
protected override bool UnitsByte { get; }
Property Value
Methods
Execute()
The actual code to be executed.
protected override void Execute()
Remarks
State is automatically set to Started before calling this method, to Complete after a successful exit and to an appropriate error state in case on an exception. You can set additional TaskStates during execution.
Exceptions
- OperationCanceledException
The operation was canceled.
- IOException
The task ended with IOError.
- WebException
The task ended with WebError.