NanoByte.Common 2.11.0
NanoByte.Common.Tasks.TaskBase Class Referenceabstract

Abstract base class for ITask implementations. More...

Inheritance diagram for NanoByte.Common.Tasks.TaskBase:
NanoByte.Common.Tasks.ITask NanoByte.Common.Net.DownloadFile NanoByte.Common.Storage.ReadDirectoryBase NanoByte.Common.Storage.ReadFile NanoByte.Common.Tasks.ForEachTask< T > NanoByte.Common.Tasks.SimplePercentTask NanoByte.Common.Tasks.SimpleTask NanoByte.Common.Threading.WaitTask NanoByte.Common.Storage.CopyDirectory NanoByte.Common.Storage.MoveDirectory

Public Member Functions

void Run (CancellationToken cancellationToken=default, ICredentialProvider? credentialProvider=null, IProgress< TaskSnapshot >? progress=null)
 Runs the task and blocks until it is complete. More...

Protected Member Functions

abstract void Execute ()
 The actual code to be executed. More...

Protected Attributes

CancellationToken CancellationToken
 Signaled when the user wishes to cancel the task execution.
 Used to retrieve credentials for specific Uris on demand; can be null.


abstract string Name [get]
object? Tag [getset]
virtual bool CanCancel [get]
TaskState State [getprotected set]
 The current State of the task.
abstract bool UnitsByte [get]
 true if UnitsProcessed and UnitsTotal are measured in bytes; false if they are measured in generic units.
long UnitsProcessed [getset]
 The number of units that have been processed so far.
long UnitsTotal [getset]
 The total number of units that are to be processed; -1 for unknown.
- Properties inherited from NanoByte.Common.Tasks.ITask
string Name [get]
 A name describing the task in human-readable form.
object? Tag [getset]
 An object used to associate the task with a specific process; can be null.
bool CanCancel [get]
 Indicates whether this task can be canceled once it has been started.

Detailed Description

Abstract base class for ITask implementations.

Member Function Documentation

◆ Execute()

abstract void NanoByte.Common.Tasks.TaskBase.Execute ( )
protectedpure virtual

The actual code to be executed.

State is automatically set to TaskState.Started before calling this method, to TaskState.Complete after a successful exit and to an appropriate error state in case on an exception. You can set additional TaskStates during execution.

OperationCanceledExceptionThe operation was canceled.
IOExceptionThe task ended with TaskState.IOError.
WebExceptionThe task ended with TaskState.WebError.

Implemented in NanoByte.Common.Net.DownloadFile, NanoByte.Common.Storage.CopyDirectory, NanoByte.Common.Storage.MoveDirectory, NanoByte.Common.Storage.ReadDirectoryBase, NanoByte.Common.Storage.ReadFile, NanoByte.Common.Tasks.ForEachTask< T >, NanoByte.Common.Tasks.SimplePercentTask, NanoByte.Common.Tasks.SimpleTask, and NanoByte.Common.Threading.WaitTask.

◆ Run()

void NanoByte.Common.Tasks.TaskBase.Run ( CancellationToken  cancellationToken = default,
ICredentialProvider credentialProvider = null,
IProgress< TaskSnapshot >?  progress = null 

Runs the task and blocks until it is complete.

Implements NanoByte.Common.Tasks.ITask.

The documentation for this class was generated from the following file: