NanoByte.Common  2.8.1
NanoByte.Common.Tasks.TaskHandlerBase Class Referenceabstract

Common base class for ITaskHandler implementations. More...

Inheritance diagram for NanoByte.Common.Tasks.TaskHandlerBase:
NanoByte.Common.MarshalNoTimeout NanoByte.Common.Tasks.ITaskHandler NanoByte.Common.Tasks.CliTaskHandler NanoByte.Common.Tasks.GuiTaskHandlerBase NanoByte.Common.Tasks.SilentTaskHandler NanoByte.Common.Tasks.AnsiCliTaskHandler NanoByte.Common.Tasks.DialogTaskHandler NanoByte.Common.Tasks.ServiceTaskHandler

Public Member Functions

virtual void Dispose ()
 
virtual void RunTask (ITask task)
 Runs an ITask and tracks its progress. Returns once the task has been completed. The task may be executed on a different thread.
 
bool Ask (string question, bool? defaultAnswer=null, string? alternateMessage=null)
 Asks the user a Yes/No/Cancel question.
 
abstract void Output (string title, string message)
 Displays multi-line text to the user.
 
virtual void Output< T > (string title, IEnumerable< T > data)
 Displays tabular data to the user.
 
virtual void Output< T > (string title, NamedCollection< T > data)
 Displays tree-like data to the user.
 
abstract void Error (Exception exception)
 Displays an error message to the user.
 
- Public Member Functions inherited from NanoByte.Common.MarshalNoTimeout
override? object InitializeLifetimeService ()
 

Protected Member Functions

abstract bool AskInteractive (string question, bool defaultAnswer)
 Asks the user a Yes/No/Cancel question. More...
 

Properties

CancellationTokenSource CancellationTokenSource = new() [get]
 Used to signal the CancellationToken. More...
 
CancellationToken CancellationToken [get]
 
virtual ? ICredentialProvider CredentialProvider [get]
 
Verbosity Verbosity [get, set]
 
virtual bool IsInteractive [get]
 Indicates whether the user can provide input. More...
 
- Properties inherited from NanoByte.Common.Tasks.ITaskHandler
CancellationToken CancellationToken [get]
 Used to signal when the user wishes to cancel the entire current process (and any ITasks it includes). More...
 
ICredentialProviderCredentialProvider [get]
 Used to ask the user or a keyring for NetworkCredentials for specific Uris; can be null. More...
 
Verbosity Verbosity [get, set]
 The detail level of messages displayed to the user. More...
 

Detailed Description

Common base class for ITaskHandler implementations.

Member Function Documentation

◆ AskInteractive()

abstract bool NanoByte.Common.Tasks.TaskHandlerBase.AskInteractive ( string  question,
bool  defaultAnswer 
)
protectedpure virtual

Asks the user a Yes/No/Cancel question.

Parameters
questionThe question and comprehensive information to help the user make an informed decision.
defaultAnswerThe default answer to preselect.
Returns
true if the user answered with 'Yes'; false if the user answered with 'No'.
Exceptions
OperationCanceledExceptionThrow if the user answered with 'Cancel'.

Implemented in NanoByte.Common.Tasks.SilentTaskHandler, NanoByte.Common.Tasks.CliTaskHandler, NanoByte.Common.Tasks.GuiTaskHandlerBase, NanoByte.Common.Tasks.DialogTaskHandler, and NanoByte.Common.Tasks.AnsiCliTaskHandler.

Property Documentation

◆ CancellationTokenSource

CancellationTokenSource NanoByte.Common.Tasks.TaskHandlerBase.CancellationTokenSource = new()
getprotected

Used to signal the CancellationToken.

◆ IsInteractive

virtual bool NanoByte.Common.Tasks.TaskHandlerBase.IsInteractive
getprotected

Indicates whether the user can provide input.


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