Class AsyncDelegateCommand
The AsyncDelegateCommand allows use the ICommand interface with asynchronous functionality. While the underlying asynchronous functionality is running CanExecute(object) always returns false and CanExecuteChanged is automatically called when execution starts and ends.
potential exceptions occurring during execution are automatically dispatched into the UI thread.
Namespace: Sartorius.SAF.Presentation.Commands
Assembly: Sartorius.SAF.Presentation.dll
Syntax
public sealed class AsyncDelegateCommand : AsyncDelegateCommandBase, IAsyncDelegateCommand, ICommand
Examples
The following example shows how to use the AsyncDelegateCommand.
Constructors
View SourceAsyncDelegateCommand(Func<Task>)
Creates a new instance of the AsyncDelegateCommand class with the specified async execution function.
Declaration
public AsyncDelegateCommand(Func<Task> executeFunc)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<Task> | executeFunc | The asynchronous function that this command should execute. |
AsyncDelegateCommand(Func<Task>, Func<bool>)
Creates a new instance of the AsyncDelegateCommand class with the specified async execution function and can execute function.
Declaration
public AsyncDelegateCommand(Func<Task> executeFunc, Func<bool> canExecute)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<Task> | executeFunc | The asynchronous function that this command should execute. |
| Func<bool> | canExecute | The function that verifies whether the command can execute in its current state. |
Methods
View SourceCanExecute()
Defines the method that determines whether the command can execute in its current state.
Declaration
public bool CanExecute()
Returns
| Type | Description |
|---|---|
| bool |
|
Execute()
Defines the method to be called when the command is invoked.
Declaration
public Task Execute()
Returns
| Type | Description |
|---|---|
| Task | The task object representing the asynchronous operation. |