Open sandboxFocus

Method CreateAsyncDelegateCommand

CreateAsyncDelegateCommand(Func<CancellationToken, Task>, Func<bool>?, bool, bool)

Creates an asynchronous command without a parameter, with cancellation support.

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

The async delegate to invoke when the command is executed. Receives a CancellationToken for cancellation support.

Func<bool> canExecute

An optional delegate that determines whether the command can execute. If null, the command can always execute.

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

A new AsyncDelegateCommand instance.

CreateAsyncDelegateCommand(Func<Task>, Func<bool>?, bool, bool)

Creates an asynchronous command without a parameter, without cancellation support.

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

The async delegate to invoke when the command is executed.

Func<bool> canExecute

An optional delegate that determines whether the command can execute. If null, the command can always execute.

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

A new AsyncDelegateCommand instance.

CreateAsyncDelegateCommand(Func<CancellationToken, Task>, Func<bool>, INotifyPropertyChanged, string, bool, bool)

Creates an asynchronous command without a parameter, with cancellation support and INotifyPropertyChanged integration.

Declaration
public static AsyncDelegateCommand CreateAsyncDelegateCommand(Func<CancellationToken, Task> execute, Func<bool> canExecute, INotifyPropertyChanged canExecuteNotifier, string canExecutePropertyName, bool supportsConcurrentExecution, bool runsInBackground)
Parameters
Type Name Description
Func<CancellationToken, Task> execute

The async delegate to invoke when the command is executed. Receives a CancellationToken for cancellation support.

Func<bool> canExecute

A delegate that determines whether the command can execute.

INotifyPropertyChanged canExecuteNotifier

The object that raises PropertyChanged when the CanExecute property changes.

string canExecutePropertyName

The name of the property that controls CanExecute.

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

A new AsyncDelegateCommand instance that automatically raises CanExecuteChanged when the specified property changes.

CreateAsyncDelegateCommand<T>(Func<T, CancellationToken, Task>, Func<T, bool>, INotifyPropertyChanged, string, bool, bool)

Creates an asynchronous command that accepts a parameter, with cancellation support and INotifyPropertyChanged integration.

Declaration
public static AsyncDelegateCommand<T> CreateAsyncDelegateCommand<T>(Func<T, CancellationToken, Task> execute, Func<T, bool> canExecute, INotifyPropertyChanged canExecuteNotifier, string canExecutePropertyName, 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

A delegate that determines whether the command can execute for a given parameter.

INotifyPropertyChanged canExecuteNotifier

The object that raises PropertyChanged when the CanExecute property changes.

string canExecutePropertyName

The name of the property that controls CanExecute.

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 that automatically raises CanExecuteChanged when the specified property changes.

Type Parameters
Name Description
T

The type of the command parameter.

CreateAsyncDelegateCommand<T>(Func<T, CancellationToken, Task>, Func<T, bool>, bool, bool)

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

Declaration
public static AsyncDelegateCommand<T> CreateAsyncDelegateCommand<T>(Func<T, CancellationToken, Task> execute, Func<T, bool> canExecute, 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

A delegate that determines whether the command can execute for a given parameter.

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.

CreateAsyncDelegateCommand<T>(Func<T, Task>, Func<T, bool>, bool, bool)

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

Declaration
public static AsyncDelegateCommand<T> CreateAsyncDelegateCommand<T>(Func<T, Task> execute, Func<T, bool> canExecute, 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

A delegate that determines whether the command can execute for a given parameter.

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.

CreateAsyncDelegateCommand(Func<Task>, Func<bool>, INotifyPropertyChanged, string, bool, bool)

Creates an asynchronous command without a parameter, without cancellation support, with INotifyPropertyChanged integration.

Declaration
public static AsyncDelegateCommand CreateAsyncDelegateCommand(Func<Task> execute, Func<bool> canExecute, INotifyPropertyChanged canExecuteNotifier, string canExecutePropertyName, bool supportsConcurrentExecution, bool runsInBackground)
Parameters
Type Name Description
Func<Task> execute

The async delegate to invoke when the command is executed.

Func<bool> canExecute

A delegate that determines whether the command can execute.

INotifyPropertyChanged canExecuteNotifier

The object that raises PropertyChanged when the CanExecute property changes.

string canExecutePropertyName

The name of the property that controls CanExecute.

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

A new AsyncDelegateCommand instance that automatically raises CanExecuteChanged when the specified property changes.