NanoByte.Common  2.4.2
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Properties | List of all members
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.DownloadTask NanoByte.Common.Storage.CopyDirectory NanoByte.Common.Tasks.ForEachTask< T > NanoByte.Common.Tasks.SimplePercentTask NanoByte.Common.Tasks.SimpleTask NanoByte.Common.Tasks.WaitTask NanoByte.Common.Net.DownloadFile NanoByte.Common.Net.DownloadMemory 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.
 

Public Attributes

virtual bool CanCancel => true
 

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. More...
 
ICredentialProviderCredentialProvider
 Used to retrieve credentials for specific Uris on demand; can be null. More...
 

Properties

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

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.

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

Implemented in NanoByte.Common.Storage.CopyDirectory, NanoByte.Common.Net.DownloadTask, NanoByte.Common.Tasks.SimplePercentTask, NanoByte.Common.Tasks.ForEachTask< T >, NanoByte.Common.Tasks.SimpleTask, NanoByte.Common.Tasks.WaitTask, and NanoByte.Common.Storage.MoveDirectory.

Member Data Documentation

◆ CancellationToken

CancellationToken NanoByte.Common.Tasks.TaskBase.CancellationToken
protected

Signaled when the user wishes to cancel the task execution.

◆ CredentialProvider

ICredentialProvider? NanoByte.Common.Tasks.TaskBase.CredentialProvider
protected

Used to retrieve credentials for specific Uris on demand; can be null.

Property Documentation

◆ State

TaskState NanoByte.Common.Tasks.TaskBase.State
getprotected setpackage

The current State of the task.

◆ UnitsByte

abstract bool NanoByte.Common.Tasks.TaskBase.UnitsByte
getprotected

true if UnitsProcessed and UnitsTotal are measured in bytes; false if they are measured in generic units.

◆ UnitsProcessed

long NanoByte.Common.Tasks.TaskBase.UnitsProcessed
getsetprotected

The number of units that have been processed so far.

◆ UnitsTotal

long NanoByte.Common.Tasks.TaskBase.UnitsTotal
getsetprotected

The total number of units that are to be processed; -1 for unknown.


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