NanoByte.Common  2.4.2
Public Member Functions | Properties | List of all members
NanoByte.Common.Tasks.ITask Interface Reference

Represents an operation that can be cancelled and have its progress tracked. More...

Inheritance diagram for NanoByte.Common.Tasks.ITask:
NanoByte.Common.Tasks.TaskBase 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. More...
 

Properties

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

Represents an operation that can be cancelled and have its progress tracked.

Unlike System.Threading.Tasks.Task, these tasks do not provide any asynchronicity by themselves. They execute all their code on the same thread they are started on and rely on ITaskHandlers for scheduling on background threads.

See also
ITaskHandler

Member Function Documentation

◆ Run()

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

Runs the task and blocks until it is complete.

Parameters
cancellationTokenUsed to receive a signal (e.g. from another thread) when the user wishes to cancel the task execution.
credentialProviderObject used to retrieve credentials for specific Uris on demand; can be null.
progressUsed to report back the task's progress (e.g. to another thread).
Exceptions
OperationCanceledExceptionThe task was canceled from another thread.
IOExceptionThe task ended with TaskState.IOError.
WebExceptionThe task ended with TaskState.WebError.
See also
ITaskHandler.RunTask

Implemented in NanoByte.Common.Tasks.TaskBase.

Property Documentation

◆ CanCancel

bool NanoByte.Common.Tasks.ITask.CanCancel
get

Indicates whether this task can be canceled once it has been started.

◆ Name

string NanoByte.Common.Tasks.ITask.Name
get

A name describing the task in human-readable form.

◆ Tag

object? NanoByte.Common.Tasks.ITask.Tag
getset

An object used to associate the task with a specific process; can be null.


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