Open sandboxFocus

Class AsyncDelegateCommand<T>

An asynchronous implementation of ICommand that uses delegates for the execute and can-execute logic, accepting a command parameter of type T. This class is typically generated by the CommandAttribute aspect for methods returning Task or when Background is true.

Inheritance
AsyncDelegateCommand<T>
Namespace: Metalama.Patterns.Wpf
Assembly: Metalama.Patterns.Wpf.dll
Syntax
public sealed class AsyncDelegateCommand<T> : BaseAsyncDelegateCommand, IAsyncCommand, ICommand, INotifyPropertyChanged
Type Parameters
Name Description
T

The type of the command parameter.

Remarks

This class implements IAsyncCommand and INotifyPropertyChanged, exposing properties like IsRunning, CanCancel, and ExecutionTask to monitor command execution state.

By default, the command cannot be executed concurrently. This can be changed via SupportsConcurrentExecution.

Methods

Name Description
CanExecute(T)

Determines whether the command can be executed with the specified parameter. Returns false if the command is already running and concurrent execution is not supported, or if the CanExecute delegate returns false.

Execute(T)

Executes the command asynchronously with the specified parameter and returns a DelegateCommandExecution that can be used to track and cancel the execution.

Extension Methods

See Also