Class ActionTask
A task that executes an System.Action that can be canceled. Only completion is reported, no intermediate progress.
public sealed class ActionTask : TaskBase, ITask
- Inheritance
-
objectMarshalByRefObjectActionTask
- Implements
- Inherited Members
- Extension Methods
Constructors
ActionTask(string, Action)
A task that executes an System.Action that cannot be canceled. Only completion is reported, no intermediate progress.
public ActionTask(string name, Action work)
Parameters
namestringA name describing the task in human-readable form.
workActionThe code to be executed by the task. May throw System.Net.WebException, System.IO.IOException or System.OperationCanceledException.
ActionTask(string, Action<CancellationToken>)
A task that executes an System.Action that can be canceled. Only completion is reported, no intermediate progress.
public ActionTask(string name, Action<CancellationToken> work)
Parameters
namestringA name describing the task in human-readable form.
workAction<CancellationToken>The code to be executed by the task. May throw System.Net.WebException, System.IO.IOException or System.OperationCanceledException.
ActionTask(string, Func<CancellationToken, Task>)
A task that executes an async System.Threading.Tasks.Task that can be canceled. Only completion is reported, no intermediate progress.
public ActionTask(string name, Func<CancellationToken, Task> work)
Parameters
namestringA name describing the task in human-readable form.
workFunc<CancellationToken, Task>The code to be executed and awaited. May throw System.Net.WebException, System.IO.IOException or System.OperationCanceledException.
ActionTask(string, Func<Task>)
A task that executes an async System.Threading.Tasks.Task that cannot be canceled. Only completion is reported, no intermediate progress.
public ActionTask(string name, Func<Task> work)
Parameters
namestringA name describing the task in human-readable form.
workFunc<Task>The code to be executed and awaited. May throw System.Net.WebException, System.IO.IOException or System.OperationCanceledException.
Properties
CanCancel
Indicates whether this task can be canceled once it has been started.
public override bool CanCancel { get; }
Property Value
- bool
Name
A name describing the task in human-readable form.
public override string Name { get; }
Property Value
- string
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
- bool
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.