Class SilentTaskHandler
Executes tasks silently and suppresses any questions.
[MustDisposeResource(false)]
public class SilentTaskHandler : ITaskHandler
- Inheritance
-
SilentTaskHandler
- Implements
- Extension Methods
Remarks
This class is thread-safe.
Properties
CancellationToken
Used to signal when the user wants to cancel the entire current process (and any ITasks it includes).
public CancellationToken CancellationToken { get; }
Property Value
Remarks
Once this has been signalled this ITaskHandler cannot be reused, since any subsequently started ITasks will be cancelled immediately.
Verbosity
Always returns Batch.
public Verbosity Verbosity { get; set; }
Property Value
Methods
Ask(string, bool?, string?)
Returns defaultAnswer
if specified or false
otherwise.
public bool Ask(string question, bool? defaultAnswer = null, string? alternateMessage = null)
Parameters
Returns
Cancel()
Cancels currently running ITasks.
public void Cancel()
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
Error(Exception)
Displays an error message to the user.
public void Error(Exception exception)
Parameters
exception
ExceptionThe exception representing the error that occurred.
Output(string, string)
Displays multi-line text to the user.
public void Output(string title, string message)
Parameters
title
stringA title for the message.
message
stringThe string to display. Trailing linebreaks are appropriately handled or ignored.
Remarks
Implementations may close the UI as a side effect. Therefore this should be your last call on the handler.
Output<T>(string, NamedCollection<T>)
Displays tree-like data to the user.
public void Output<T>(string title, NamedCollection<T> data) where T : INamed
Parameters
title
stringA title for the data.INamed
data
NamedCollection<T>The data to display.
Type Parameters
T
Remarks
Implementations may close the UI as a side effect. Therefore this should be your last call on the handler.
Output<T>(string, IEnumerable<T>)
Displays tabular data to the user.
public void Output<T>(string title, IEnumerable<T> data)
Parameters
title
stringA title for the data.
data
IEnumerable<T>The data to display.
Type Parameters
T
Remarks
Implementations may close the UI as a side effect. Therefore this should be your last call on the handler.
RunTask(ITask)
Runs an ITask and tracks its progress. Returns once the task has been completed.
public void RunTask(ITask task)
Parameters
task
ITaskThe task to be run. (Run(CancellationToken, ICredentialProvider?, IProgress<TaskSnapshot>?) or equivalent is called on it.)
Exceptions
- OperationCanceledException
The user canceled the task.
- IOException
The task ended with IOError.
- WebException
The task ended with WebError.