Interface ITask
Represents an operation that can be cancelled and have its progress tracked.
Namespace: NanoByte.Common.Tasks
Assembly: NanoByte.Common.dll
Syntax
public interface ITask
Properties
CanCancel
Indicates whether this task can be canceled once it has been started.
Declaration
bool CanCancel { get; }
Property Value
Type | Description |
---|---|
Boolean |
Name
A name describing the task in human-readable form.
Declaration
string Name { get; }
Property Value
Type | Description |
---|---|
String |
Tag
An object used to associate the task with a specific process; can be null
.
Declaration
object Tag { get; set; }
Property Value
Type | Description |
---|---|
Object |
Methods
Run(CancellationToken, ICredentialProvider, IProgress<TaskSnapshot>)
Runs the task and blocks until it is complete.
Declaration
void Run(CancellationToken cancellationToken = null, ICredentialProvider credentialProvider = null, IProgress<TaskSnapshot> progress = null)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancellationToken | Used to receive a signal (e.g. from another thread) when the user wants to cancel the task. |
ICredentialProvider | credentialProvider | Object used to retrieve credentials for specific Uris on demand; can be |
IProgress<TaskSnapshot> | progress | Used to report back the task's progress (e.g. to another thread). |
Exceptions
Type | Condition |
---|---|
OperationCanceledException | The task was canceled from another thread. |
IOException | The task ended with IOError. |
WebException | The task ended with WebError. |