NanoByte.Common
2.6.1
|
Used to execute and track ITasks and ask the user questions. Specific implementations provide different kinds of user interfaces. More...
Public Member Functions | |
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. More... | |
bool | Ask ([Localizable(true)] string question, bool? defaultAnswer=null, [Localizable(true)] string? alternateMessage=null) |
Asks the user a Yes/No/Cancel question. More... | |
void | Output ([Localizable(true)] string title, [Localizable(true)] string message) |
Displays multi-line text to the user. More... | |
void | Output< T > ([Localizable(true)] string title, IEnumerable< T > data) |
Displays tabular data to the user. More... | |
void | Output< T > ([Localizable(true)] string title, NamedCollection< T > data) |
Displays tree-like data to the user. More... | |
void | Error (Exception exception) |
Displays an error message to the user. More... | |
Properties | |
CancellationToken | CancellationToken [get] |
Used to signal when the user wishes to cancel the entire current process (and any ITasks it includes). More... | |
ICredentialProvider? | CredentialProvider [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... | |
Used to execute and track ITasks and ask the user questions. Specific implementations provide different kinds of user interfaces.
The methods may be called from a background thread. Implementations need to apply appropriate thread-synchronization to update UI elements. Implementations should derive from MarshalNoTimeout.
bool NanoByte.Common.Tasks.ITaskHandler.Ask | ( | [Localizable(true)] string | question, |
bool? | defaultAnswer = null , |
||
[Localizable(true)] string? | alternateMessage = null |
||
) |
Asks the user a Yes/No/Cancel question.
question | The question and comprehensive information to help the user make an informed decision. |
defaultAnswer | An answer to choose automatically when Verbosity is Tasks.Verbosity.Batch or lower. null if the user must make the choice themselves. |
alternateMessage | A message to output with Log.Warn(string) when the defaultAnswer is used instead of asking the user. |
true
if the user answered with 'Yes'; false
if the user answered with 'No'.OperationCanceledException | The user selected 'Cancel'. |
Implemented in NanoByte.Common.Tasks.TaskHandlerBase, NanoByte.Common.Tasks.SilentTaskHandler, NanoByte.Common.Tasks.CliTaskHandler, NanoByte.Common.Tasks.GuiTaskHandlerBase, and NanoByte.Common.Tasks.DialogTaskHandler.
void NanoByte.Common.Tasks.ITaskHandler.Error | ( | Exception | exception | ) |
Displays an error message to the user.
exception | The exception representing the error that occurred. |
Implemented in NanoByte.Common.Tasks.TaskHandlerBase, NanoByte.Common.Tasks.SilentTaskHandler, NanoByte.Common.Tasks.CliTaskHandler, NanoByte.Common.Tasks.GuiTaskHandlerBase, and NanoByte.Common.Tasks.DialogTaskHandler.
void NanoByte.Common.Tasks.ITaskHandler.Output | ( | [Localizable(true)] string | title, |
[Localizable(true)] string | message | ||
) |
Displays multi-line text to the user.
title | A title for the message. |
message | The string to display. Trailing linebreaks are appropriately handled or ignored. |
Implementations may close the UI as a side effect. Therefore this should be your last call on the handler.
Implemented in NanoByte.Common.Tasks.TaskHandlerBase, NanoByte.Common.Tasks.SilentTaskHandler, NanoByte.Common.Tasks.CliTaskHandler, NanoByte.Common.Tasks.GuiTaskHandlerBase, and NanoByte.Common.Tasks.DialogTaskHandler.
void NanoByte.Common.Tasks.ITaskHandler.Output< T > | ( | [Localizable(true)] string | title, |
IEnumerable< T > | data | ||
) |
Displays tabular data to the user.
title | A title for the data.INamed |
data | The data to display. |
Implementations may close the UI as a side effect. Therefore this should be your last call on the handler.
Implemented in NanoByte.Common.Tasks.TaskHandlerBase, NanoByte.Common.Tasks.SilentTaskHandler, NanoByte.Common.Tasks.GuiTaskHandlerBase, and NanoByte.Common.Tasks.DialogTaskHandler.
void NanoByte.Common.Tasks.ITaskHandler.Output< T > | ( | [Localizable(true)] string | title, |
NamedCollection< T > | data | ||
) |
Displays tree-like data to the user.
title | A title for the data.INamed |
data | The data to display. |
Implementations may close the UI as a side effect. Therefore this should be your last call on the handler.
Implemented in NanoByte.Common.Tasks.TaskHandlerBase, NanoByte.Common.Tasks.SilentTaskHandler, and NanoByte.Common.Tasks.GuiTaskHandlerBase.
T | : | INamed |
void NanoByte.Common.Tasks.ITaskHandler.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.
task | The task to be run. (ITask.Run or equivalent is called on it.) |
OperationCanceledException | The user canceled the task. |
IOException | The task ended with TaskState.IOError. |
WebException | The task ended with TaskState.WebError. |
This may be called multiple times concurrently but concurrent calls must not depend on each other. The specific implementation of this method determines whether the tasks actually run concurrently or in sequence.
Implemented in NanoByte.Common.Tasks.TaskHandlerBase, NanoByte.Common.Tasks.SilentTaskHandler, NanoByte.Common.Tasks.CliTaskHandler, and NanoByte.Common.Tasks.DialogTaskHandler.
|
get |
Used to signal when the user wishes to cancel the entire current process (and any ITasks it includes).
Once this has been signalled this ITaskHandler cannot be reused, since any subsequently started ITasks will be cancelled immediately.
|
get |
Used to ask the user or a keyring for NetworkCredentials for specific Uris; can be null
.
|
getset |
The detail level of messages displayed to the user.