Open sandboxFocus

Method CreateParametricAsyncDelegateCommand

CreateParametricAsyncDelegateCommand<T>(Func<T, CancellationToken, Task>, Func<T, bool>?, bool, bool, bool)

Creates an asynchronous command that accepts a parameter, with configurable cancellation support.

Declaration
public static AsyncDelegateCommand<T> CreateParametricAsyncDelegateCommand<T>(Func<T, CancellationToken, Task> execute, Func<T, bool>? canExecute, bool supportsCancellation, bool supportsConcurrentExecution, bool runsInBackground)
Parameters
Type Name Description
Func<T, CancellationToken, Task> execute

The async delegate to invoke when the command is executed. Receives the parameter and a CancellationToken.

Func<T, bool> canExecute

An optional delegate that determines whether the command can execute for a given parameter. If null, the command can always execute.

bool supportsCancellation

If true, enables cancellation support via CancellationToken.

bool supportsConcurrentExecution

If true, allows multiple concurrent executions of the command.

bool runsInBackground

If true, the execution is dispatched to a background thread via Run(Func<Task>, CancellationToken).

Returns
Type Description
AsyncDelegateCommand<T>

A new AsyncDelegateCommand<T> instance.

Type Parameters
Name Description
T

The type of the command parameter.

CreateParametricAsyncDelegateCommand<T>(Func<T, Task>, Func<T, bool>?, bool, bool, bool)

Creates an asynchronous command that accepts a parameter, without cancellation token in the delegate, with configurable cancellation support.

Declaration
public static AsyncDelegateCommand<T> CreateParametricAsyncDelegateCommand<T>(Func<T, Task> execute, Func<T, bool>? canExecute, bool supportsCancellation, bool supportsConcurrentExecution, bool runsInBackground)
Parameters
Type Name Description
Func<T, Task> execute

The async delegate to invoke when the command is executed.

Func<T, bool> canExecute

An optional delegate that determines whether the command can execute for a given parameter. If null, the command can always execute.

bool supportsCancellation

If true, enables cancellation support (though the delegate won't receive the token).

bool supportsConcurrentExecution

If true, allows multiple concurrent executions of the command.

bool runsInBackground

If true, the execution is dispatched to a background thread via Run(Func<Task>, CancellationToken).

Returns
Type Description
AsyncDelegateCommand<T>

A new AsyncDelegateCommand<T> instance.

Type Parameters
Name Description
T

The type of the command parameter.