Class DialogTaskHandler
Uses simple WinForms dialog boxes to inform the user about the progress of tasks.
[MustDisposeResource]
public class DialogTaskHandler : GuiTaskHandlerBase, ITaskHandler
- Inheritance
-
objectDialogTaskHandler
- Implements
- Inherited Members
- Extension Methods
Remarks
This class is thread-safe.
Constructors
DialogTaskHandler(Control)
Creates a new dialog task handler. Registers a Handler.
public DialogTaskHandler(Control owner)
Parameters
owner
ControlThe parent window for any dialogs created by the handler.
Methods
AskInteractive(string, bool)
Asks the user a Yes/No/Cancel question.
protected override bool AskInteractive(string question, bool defaultAnswer)
Parameters
question
stringThe question and comprehensive information to help the user make an informed decision.
defaultAnswer
boolThe default answer to preselect.
Returns
- bool
true
if the user answered with 'Yes';false
if the user answered with 'No'.
Exceptions
- OperationCanceledException
Throw if the user answered with 'Cancel'.
Error(Exception)
Displays an error message to the user.
public override void Error(Exception exception)
Parameters
exception
ExceptionThe exception representing the error that occurred.
Output(string, string)
Displays multi-line text to the user.
public override 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, IEnumerable<T>)
Displays tabular data to the user.
public override 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 override void RunTask(ITask task)
Parameters
task
ITaskThe task to be run. (Run(CancellationToken, ICredentialProvider?, IProgress<TaskSnapshot>?) or equivalent is called on it.)