IInteractionService Methods
PromptConfirmationAsync(string, string, MessageBoxInteractionOptions?, CancellationToken) Section titled PromptConfirmationAsync(string, string, MessageBoxInteractionOptions?, CancellationToken)abstractTask<InteractionResult<bool>> public interface IInteractionService{ public abstract Task<InteractionResult<bool>> PromptConfirmationAsync( string title, string message, MessageBoxInteractionOptions? options = null, CancellationToken cancellationToken = default(CancellationToken)) { // ... }}Parameters
titlestringThe title of the dialog.messagestringThe message to display in the dialog.optionsMessagecancellationToken CancellationToken optionalA token to cancel the operation.Returns
Task<InteractionResult<bool>> An Hosting.InteractionResult`1 containing true if the user confirmed, false otherwise. PromptInputAsync(string, string?, string, string, InputsDialogInteractionOptions?, CancellationToken) Section titled PromptInputAsync(string, string?, string, string, InputsDialogInteractionOptions?, CancellationToken)abstractTask<InteractionResult<InteractionInput>> public interface IInteractionService{ public abstract Task<InteractionResult<InteractionInput>> PromptInputAsync( string title, string? message, string inputLabel, string placeHolder, InputsDialogInteractionOptions? options = null, CancellationToken cancellationToken = default(CancellationToken)) { // ... }}Parameters
titlestringThe title of the input dialog.messagestring?The message to display in the dialog.inputLabel stringThe label for the input field.placeHolder stringThe placeholder text for the input field.optionsInputscancellationToken CancellationToken optionalA token to cancel the operation.Returns
Task<InteractionResult<InteractionInput>> An Hosting.InteractionResult`1 containing the user's input. PromptInputAsync(string, string?, InteractionInput, InputsDialogInteractionOptions?, CancellationToken) Section titled PromptInputAsync(string, string?, InteractionInput, InputsDialogInteractionOptions?, CancellationToken)abstractTask<InteractionResult<InteractionInput>> InteractionInput . public interface IInteractionService{ public abstract Task<InteractionResult<InteractionInput>> PromptInputAsync( string title, string? message, InteractionInput input, InputsDialogInteractionOptions? options = null, CancellationToken cancellationToken = default(CancellationToken)) { // ... }}Parameters
titlestringThe title of the input dialog.messagestring?The message to display in the dialog.inputInteractionoptionsInputscancellationToken CancellationToken optionalA token to cancel the operation.Returns
Task<InteractionResult<InteractionInput>> An Hosting.InteractionResult`1 containing the user's input. PromptInputsAsync(string, string?, IReadOnlyList<InteractionInput>, InputsDialogInteractionOptions?, CancellationToken) Section titled PromptInputsAsync(string, string?, IReadOnlyList<InteractionInput>, InputsDialogInteractionOptions?, CancellationToken)abstractTask<InteractionResult<InteractionInputCollection>> public interface IInteractionService{ public abstract Task<InteractionResult<InteractionInputCollection>> PromptInputsAsync( string title, string? message, IReadOnlyList<InteractionInput> inputs, InputsDialogInteractionOptions? options = null, CancellationToken cancellationToken = default(CancellationToken)) { // ... }}Parameters
titlestringThe title of the input dialog.messagestring?The message to display in the dialog.inputsIInteractionInput to prompt for.optionsInputscancellationToken CancellationToken optionalA token to cancel the operation.Returns
Task<InteractionResult<InteractionInputCollection>> An Hosting.InteractionResult`1 containing the user's inputs as an InteractionInputCollection . PromptMessageBoxAsync(string, string, MessageBoxInteractionOptions?, CancellationToken) Section titled PromptMessageBoxAsync(string, string, MessageBoxInteractionOptions?, CancellationToken)abstractTask<InteractionResult<bool>> public interface IInteractionService{ public abstract Task<InteractionResult<bool>> PromptMessageBoxAsync( string title, string message, MessageBoxInteractionOptions? options = null, CancellationToken cancellationToken = default(CancellationToken)) { // ... }}Parameters
titlestringThe title of the message box.messagestringThe message to display in the message box.optionsMessagecancellationToken CancellationToken optionalA token to cancel the operation.Returns
Task<InteractionResult<bool>> An Hosting.InteractionResult`1 containing true if the user accepted, false otherwise. PromptNotificationAsync(string, string, NotificationInteractionOptions?, CancellationToken) Section titled PromptNotificationAsync(string, string, NotificationInteractionOptions?, CancellationToken)abstractTask<InteractionResult<bool>> public interface IInteractionService{ public abstract Task<InteractionResult<bool>> PromptNotificationAsync( string title, string message, NotificationInteractionOptions? options = null, CancellationToken cancellationToken = default(CancellationToken)) { // ... }}Parameters
titlestringThe title of the notification.messagestringThe message to display in the notification.optionsNotificationcancellationToken CancellationToken optionalA token to cancel the operation.Returns
Task<InteractionResult<bool>> An Hosting.InteractionResult`1 containing true if the user accepted, false otherwise. PromptProgressAsync(string, ProgressInteractionOptions?, CancellationToken) Section titled PromptProgressAsync(string, ProgressInteractionOptions?, CancellationToken)abstractTask<InteractionResult<bool>> public interface IInteractionService{ public abstract Task<InteractionResult<bool>> PromptProgressAsync( string message, ProgressInteractionOptions? options = null, CancellationToken cancellationToken = default(CancellationToken)) { // ... }}Parameters
messagestringThe message to display in the progress dialog.optionsProgresscancellationToken CancellationToken optionalA token to cancel the operation and close the dialog.Returns
Task<InteractionResult<bool>> An Hosting.InteractionResult`1 containing true if the operation completed successfully, or a canceled result if the user clicked the cancel button. Remarks
The dialog displays a spinning progress wheel and can optionally include a title, message, and a cancel button.
If Progress is provided, the dialog remains open while the callback executes and closes automatically when it completes. If no callback is provided, the dialog remains open until cancellation is canceled.
When a button is shown (via Interaction), clicking it signals cancellation through the Progress provided to the work callback.
PromptTerminalAsync(string, AspireTerminal, TerminalInteractionOptions?, CancellationToken) Section titled PromptTerminalAsync(string, AspireTerminal, TerminalInteractionOptions?, CancellationToken)abstractTask<InteractionResult<bool>> public interface IInteractionService{ public abstract Task<InteractionResult<bool>> PromptTerminalAsync( string message, AspireTerminal terminal, TerminalInteractionOptions? options = null, CancellationToken cancellationToken = default(CancellationToken)) { // ... }}Parameters
messagestringThe message to display above the terminal.terminalAspireTerminalPlacement.Dialog placement.optionsTerminalcancellationToken CancellationToken optionalA token to cancel the interaction and signal cancellation to the work callback.Returns
Task<InteractionResult<bool>> An Hosting.InteractionResult`1 containing true when work or an explicit completion succeeds, or a canceled result when the user or caller cancels the interaction. Exceptions
ArgumentNullExceptionmessage or terminal is null.InvalidOperationException The interaction service is unavailable, the terminal is not registered with this AppHost, or its placement is not TerminalPlacement.Dialog . OperationCanceledExceptioncancellationToken was canceled before the interaction began.Remarks
Create and start the terminal before prompting, and dispose it when the caller is finished with it. The interaction borrows the terminal: completion, cancellation, and viewer disconnection do not stop or dispose it. The same terminal can be reused across prompts. The terminal process exiting does not close the dialog.
When Terminal is supplied, successful completion closes the dialog. The optional Interaction labels a cancel button, not a submit button. User or external cancellation closes the dialog and signals Terminal; this method waits for the callback to finish before returning. Non-cancellation callback exceptions are propagated after the interaction is removed. Without a callback, the dialog waits for explicit completion, the cancel button, or cancellation.
Secondary and dismiss buttons are not shown. Disconnecting a viewer does not complete the interaction; reconnecting can display the pending dialog again.
Examples
await using var terminal = terminalService.CreateTerminal(new TerminalLaunchOptions{ Title = "Setup", Executable = "./setup.sh", Placement = TerminalPlacement.Dialog});terminal.Start();var result = await interactionService.PromptTerminalAsync("Running setup.", terminal, new TerminalInteractionOptions { Title = "Setup", PrimaryButtonText = "Cancel", Work = async context => { await terminal.WaitForTextAsync("Continue? ", cancellationToken: context.CancellationToken); await terminal.SendTextAsync("y\r", context.CancellationToken); await terminal.WaitForTextAsync("Setup complete", cancellationToken: context.CancellationToken); } }, cancellationToken);