Class AsyncRelayCommand
A command that mirrors the functionality of RelayCommand, with the addition of accepting a Func<TResult> returning a Task as the execute action, and providing an executionTask property that notifies changes when ExecuteAsync(object?) is invoked and when the returned Task completes.
Inherited Members
Namespace: Unity.AppUI.MVVM
Assembly: solution.dll
Syntax
public class AsyncRelayCommand : IAsyncRelayCommand, IRelayCommand, ICommand, INotifyPropertyChanged
Constructors
| Name | Description |
|---|---|
| AsyncRelayCommand(Func<CancellationToken, Task>) | Initializes a new instance of the AsyncRelayCommand class. |
| AsyncRelayCommand(Func<CancellationToken, Task>, Func<bool>) | Initializes a new instance of the AsyncRelayCommand class. |
| AsyncRelayCommand(Func<CancellationToken, Task>, Func<bool>, AsyncRelayCommandOptions) | Initializes a new instance of the AsyncRelayCommand class. |
| AsyncRelayCommand(Func<CancellationToken, Task>, AsyncRelayCommandOptions) | Initializes a new instance of the AsyncRelayCommand class. |
| AsyncRelayCommand(Func<Task>) | Initializes a new instance of the AsyncRelayCommand class. |
| AsyncRelayCommand(Func<Task>, Func<bool>) | Initializes a new instance of the AsyncRelayCommand class. |
| AsyncRelayCommand(Func<Task>, Func<bool>, AsyncRelayCommandOptions) | Initializes a new instance of the AsyncRelayCommand class. |
| AsyncRelayCommand(Func<Task>, AsyncRelayCommandOptions) | Initializes a new instance of the AsyncRelayCommand class. |
Fields
| Name | Description |
|---|---|
| CanBeCanceledChangedEventArgs | The arguments for the PropertyChanged event raised by the canBeCancelled property. |
| ExecutionTaskChangedEventArgs | The arguments for the PropertyChanged event raised by the executionTask property. |
| IsCancellationRequestedChangedEventArgs | The arguments for the PropertyChanged event raised by the isCancellationRequested property. |
| IsRunningChangedEventArgs | The arguments for the PropertyChanged event raised by the isRunning property. |
Properties
| Name | Description |
|---|---|
| canBeCancelled | Gets the CancellationTokenSource that can be used to cancel the asynchronous operation. |
| executionTask | Gets the Task that represents the asynchronous operation. |
| isCancellationRequested | Gets the CancellationTokenSource that can be used to cancel the asynchronous operation. |
| isRunning | Gets the CancellationTokenSource that can be used to cancel the asynchronous operation. |
Methods
| Name | Description |
|---|---|
| CanExecute() | Determines whether this AsyncRelayCommand can execute in its current state. |
| CanExecute(object?) | Determines whether this AsyncRelayCommand can execute in its current state. |
| Cancel() | Cancels the AsyncRelayCommand on the current command target. |
| Execute() | Executes the AsyncRelayCommand on the current command target. |
| Execute(object?) | Executes the AsyncRelayCommand on the current command target. |
| ExecuteAsync(object?) | Executes the AsyncRelayCommand on the current command target. |
| NotifyCanExecuteChanged() | Raises the CanExecuteChanged event. |
Events
| Name | Description |
|---|---|
| CanExecuteChanged | Event that is raised when changes occur that affect whether or not the AsyncRelayCommand should execute. |
| PropertyChanged | Event that is raised when the executionTask property changes. |