Interface IAsyncRelayCommand
An interface expanding IRelayCommand to support asynchronous operations.
Inherited Members
Namespace: Unity.AppUI.MVVM
Assembly: Unity.AppUI.MVVM.dll
Syntax
public interface IAsyncRelayCommand : IRelayCommand, ICommand, INotifyPropertyChanged
Properties
canBeCancelled
Gets a value indicating whether a running operation for this command can currently be canceled.
Declaration
bool canBeCancelled { get; }
Property Value
Type | Description |
---|---|
bool |
Remarks
The exact sequence of events that types implementing this interface should raise is as follows:
- The command is initially not running: isRunning, canBeCancelled and isCancellationRequested are false.
- The command starts running: isRunning and canBeCancelled switch to true. isCancellationRequested is set to false.
- If the operation is canceled: canBeCancelled switches to false and isCancellationRequested switches to true.
- The operation completes: isRunning and canBeCancelled switch to false. The state of isCancellationRequested is undefined.
executionTask
Gets the last scheduled Task, if available. This property notifies a change when the Task completes.
Declaration
Task? executionTask { get; }
Property Value
Type | Description |
---|---|
Task |
isCancellationRequested
Gets a value indicating whether a running operation for this command has been cancelled.
Declaration
bool isCancellationRequested { get; }
Property Value
Type | Description |
---|---|
bool |
isRunning
Gets a value indicating whether an operation for this command is currently running.
Declaration
bool isRunning { get; }
Property Value
Type | Description |
---|---|
bool |
Methods
Cancel()
Attempts to cancel the currently running operation for this command.
Declaration
void Cancel()
ExecuteAsync(object?)
Executes the command asynchronously.
Declaration
Task ExecuteAsync(object? parameter)
Parameters
Type | Name | Description |
---|---|---|
object | parameter | The input parameter. |
Returns
Type | Description |
---|---|
Task | A Task representing the asynchronous operation. |