Class AsyncRelayCommand
A command that mirrors the functionality of Relay
Inherited Members
Namespace: Unity.AppUI.MVVM
Assembly: Unity.AppUI.MVVM.dll
Syntax
public class AsyncRelayCommand : IAsyncRelayCommand, IRelayCommand, ICommand, INotifyPropertyChanged
Constructors
AsyncRelayCommand(Func<CancellationToken, Task>)
Initializes a new instance of the Async
Declaration
public AsyncRelayCommand(Func<CancellationToken, Task> cancellableExecute)
Parameters
Type | Name | Description |
---|---|---|
Func<Cancellation |
cancellableExecute | The Func<TResult> to invoke when Execute |
Exceptions
Type | Condition |
---|---|
Argument |
If the execute argument is null. |
AsyncRelayCommand(Func<CancellationToken, Task>, Func<bool>)
Initializes a new instance of the Async
Declaration
public AsyncRelayCommand(Func<CancellationToken, Task> cancellableExecute, Func<bool> canExecute)
Parameters
Type | Name | Description |
---|---|---|
Func<Cancellation |
cancellableExecute | The Func<TResult> to invoke when Execute |
Func<bool> | canExecute | The Func<TResult> to invoke when Can |
Exceptions
Type | Condition |
---|---|
Argument |
If the execute argument is null. |
AsyncRelayCommand(Func<CancellationToken, Task>, Func<bool>, AsyncRelayCommandOptions)
Initializes a new instance of the Async
Declaration
public AsyncRelayCommand(Func<CancellationToken, Task> cancellableExecute, Func<bool> canExecute, AsyncRelayCommandOptions options)
Parameters
Type | Name | Description |
---|---|---|
Func<Cancellation |
cancellableExecute | The Func<TResult> to invoke when Execute |
Func<bool> | canExecute | The Func<TResult> to invoke when Can |
Async |
options | The Async |
Exceptions
Type | Condition |
---|---|
Argument |
If the execute argument is null. |
AsyncRelayCommand(Func<CancellationToken, Task>, AsyncRelayCommandOptions)
Initializes a new instance of the Async
Declaration
public AsyncRelayCommand(Func<CancellationToken, Task> cancellableExecute, AsyncRelayCommandOptions options)
Parameters
Type | Name | Description |
---|---|---|
Func<Cancellation |
cancellableExecute | The Func<TResult> to invoke when Execute |
Async |
options | The Async |
Exceptions
Type | Condition |
---|---|
Argument |
If the execute argument is null. |
AsyncRelayCommand(Func<Task>)
Initializes a new instance of the Async
Declaration
public AsyncRelayCommand(Func<Task> execute)
Parameters
Type | Name | Description |
---|---|---|
Func<Task> | execute | The Func<TResult> to invoke when Execute |
Exceptions
Type | Condition |
---|---|
Argument |
If the execute argument is null. |
AsyncRelayCommand(Func<Task>, Func<bool>)
Initializes a new instance of the Async
Declaration
public AsyncRelayCommand(Func<Task> execute, Func<bool> canExecute)
Parameters
Type | Name | Description |
---|---|---|
Func<Task> | execute | The Func<TResult> to invoke when Execute |
Func<bool> | canExecute | The Func<TResult> to invoke when Can |
Exceptions
Type | Condition |
---|---|
Argument |
If the execute argument is null. |
AsyncRelayCommand(Func<Task>, Func<bool>, AsyncRelayCommandOptions)
Initializes a new instance of the Async
Declaration
public AsyncRelayCommand(Func<Task> execute, Func<bool> canExecute, AsyncRelayCommandOptions options)
Parameters
Type | Name | Description |
---|---|---|
Func<Task> | execute | The Func<TResult> to invoke when Execute |
Func<bool> | canExecute | The Func<TResult> to invoke when Can |
Async |
options | The Async |
Exceptions
Type | Condition |
---|---|
Argument |
If the execute argument is null. |
AsyncRelayCommand(Func<Task>, AsyncRelayCommandOptions)
Initializes a new instance of the Async
Declaration
public AsyncRelayCommand(Func<Task> execute, AsyncRelayCommandOptions options)
Parameters
Type | Name | Description |
---|---|---|
Func<Task> | execute | The Func<TResult> to invoke when Execute |
Async |
options | The Async |
Exceptions
Type | Condition |
---|---|
Argument |
If the execute argument is null. |
Fields
CanBeCanceledChangedEventArgs
The arguments for the Property
Declaration
public static readonly PropertyChangedEventArgs CanBeCanceledChangedEventArgs
Field Value
Type | Description |
---|---|
Property |
ExecutionTaskChangedEventArgs
The arguments for the Property
Declaration
public static readonly PropertyChangedEventArgs ExecutionTaskChangedEventArgs
Field Value
Type | Description |
---|---|
Property |
IsCancellationRequestedChangedEventArgs
The arguments for the Property
Declaration
public static readonly PropertyChangedEventArgs IsCancellationRequestedChangedEventArgs
Field Value
Type | Description |
---|---|
Property |
IsRunningChangedEventArgs
The arguments for the Property
Declaration
public static readonly PropertyChangedEventArgs IsRunningChangedEventArgs
Field Value
Type | Description |
---|---|
Property |
Properties
canBeCancelled
Gets the Cancellation
Declaration
public bool canBeCancelled { get; }
Property Value
Type | Description |
---|---|
bool |
executionTask
Gets the Task that represents the asynchronous operation.
Declaration
public Task? executionTask { get; set; }
Property Value
Type | Description |
---|---|
Task |
isCancellationRequested
Gets the Cancellation
Declaration
public bool isCancellationRequested { get; }
Property Value
Type | Description |
---|---|
bool |
isRunning
Gets the Cancellation
Declaration
public bool isRunning { get; }
Property Value
Type | Description |
---|---|
bool |
Methods
CanExecute()
Determines whether this Async
Declaration
public bool CanExecute()
Returns
Type | Description |
---|---|
bool | true if this Async |
CanExecute(object?)
Determines whether this Async
Declaration
public bool CanExecute(object? parameter)
Parameters
Type | Name | Description |
---|---|---|
object | parameter | The parameter to use when determining whether this Async |
Returns
Type | Description |
---|---|
bool | true if this Async |
Cancel()
Cancels the Async
Declaration
public void Cancel()
Execute()
Executes the Async
Declaration
public void Execute()
Execute(object?)
Executes the Async
Declaration
public void Execute(object? parameter)
Parameters
Type | Name | Description |
---|---|---|
object | parameter | The parameter to use when executing the Async |
ExecuteAsync(object?)
Executes the Async
Declaration
public Task ExecuteAsync(object? parameter)
Parameters
Type | Name | Description |
---|---|---|
object | parameter | The parameter to use when executing the Async |
Returns
NotifyCanExecuteChanged()
Raises the Can
Declaration
public void NotifyCanExecuteChanged()
Events
CanExecuteChanged
Event that is raised when changes occur that affect whether or not the Async
Declaration
public event EventHandler? CanExecuteChanged
Event Type
Type | Description |
---|---|
Event |
PropertyChanged
Event that is raised when the execution
Declaration
public event PropertyChangedEventHandler? PropertyChanged
Event Type
Type | Description |
---|---|
Property |