Class AsyncRelayCommand
A _command that mirrors the functionality of RelayCommand, with the addition of
accepting a
Inheritance
Namespace: ISynergy.Framework.Mvvm.Commands
Assembly: ISynergy.Framework.Mvvm.dll
Syntax
public sealed class AsyncRelayCommand : object, IAsyncRelayCommand, IRelayCommand
Constructors
View SourceAsyncRelayCommand(Func<CancellationToken, Task>)
Initializes a new instance of the AsyncRelayCommand class.
Declaration
public AsyncRelayCommand(Func<CancellationToken, Task> cancelableExecute)
Parameters
Type | Name | Description |
---|---|---|
Func<CancellationToken, Task> | cancelableExecute | The cancelable execution logic. |
AsyncRelayCommand(Func<CancellationToken, Task>, Func<Boolean>)
Initializes a new instance of the AsyncRelayCommand class.
Declaration
public AsyncRelayCommand(Func<CancellationToken, Task> cancelableExecute, Func<bool> canExecute)
Parameters
Type | Name | Description |
---|---|---|
Func<CancellationToken, Task> | cancelableExecute | The cancelable execution logic. |
Func<System.Boolean> | canExecute | The execution status logic. |
AsyncRelayCommand(Func<CancellationToken, Task>, Func<Boolean>, AsyncRelayCommandOptions)
Initializes a new instance of the AsyncRelayCommand class.
Declaration
public AsyncRelayCommand(Func<CancellationToken, Task> cancelableExecute, Func<bool> canExecute, AsyncRelayCommandOptions options)
Parameters
Type | Name | Description |
---|---|---|
Func<CancellationToken, Task> | cancelableExecute | The cancelable execution logic. |
Func<System.Boolean> | canExecute | The execution status logic. |
AsyncRelayCommandOptions | options | The _options to use to configure the async _command. |
AsyncRelayCommand(Func<CancellationToken, Task>, AsyncRelayCommandOptions)
Initializes a new instance of the AsyncRelayCommand class.
Declaration
public AsyncRelayCommand(Func<CancellationToken, Task> cancelableExecute, AsyncRelayCommandOptions options)
Parameters
Type | Name | Description |
---|---|---|
Func<CancellationToken, Task> | cancelableExecute | The cancelable execution logic. |
AsyncRelayCommandOptions | options | The _options to use to configure the async _command. |
AsyncRelayCommand(Func<Task>)
Initializes a new instance of the AsyncRelayCommand class.
Declaration
public AsyncRelayCommand(Func<Task> execute)
Parameters
Type | Name | Description |
---|---|---|
Func<Task> | execute | The execution logic. |
AsyncRelayCommand(Func<Task>, Func<Boolean>)
Initializes a new instance of the AsyncRelayCommand class.
Declaration
public AsyncRelayCommand(Func<Task> execute, Func<bool> canExecute)
Parameters
Type | Name | Description |
---|---|---|
Func<Task> | execute | The execution logic. |
Func<System.Boolean> | canExecute | The execution status logic. |
AsyncRelayCommand(Func<Task>, Func<Boolean>, AsyncRelayCommandOptions)
Initializes a new instance of the AsyncRelayCommand class.
Declaration
public AsyncRelayCommand(Func<Task> execute, Func<bool> canExecute, AsyncRelayCommandOptions options)
Parameters
Type | Name | Description |
---|---|---|
Func<Task> | execute | The execution logic. |
Func<System.Boolean> | canExecute | The execution status logic. |
AsyncRelayCommandOptions | options | The _options to use to configure the async _command. |
AsyncRelayCommand(Func<Task>, AsyncRelayCommandOptions)
Initializes a new instance of the AsyncRelayCommand class.
Declaration
public AsyncRelayCommand(Func<Task> execute, AsyncRelayCommandOptions options)
Parameters
Type | Name | Description |
---|---|---|
Func<Task> | execute | The execution logic. |
AsyncRelayCommandOptions | options | The _options to use to configure the async _command. |
Properties
View SourceCanBeCanceled
Gets a value indicating whether a running operation for this command can currently be canceled.
Declaration
public bool CanBeCanceled { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Remarks
The exact sequence of events that types implementing this interface should raise is as follows:
- The command is initially not running: IsRunning, CanBeCanceled and IsCancellationRequested are false.
- The command starts running: IsRunning and CanBeCanceled switch to true. IsCancellationRequested is set to false.
- If the operation is canceled: CanBeCanceled switches to false and IsCancellationRequested switches to true.
- The operation completes: IsRunning and CanBeCanceled switch to false. The state of IsCancellationRequested is undefined.
ExecutionTask
Gets the last scheduled
Declaration
public Task? ExecutionTask { get; }
Property Value
Type | Description |
---|---|
System.Nullable<Task> |
IsCancellationRequested
Gets a value indicating whether a cancelation request has been issued for the current operation.
Declaration
public bool IsCancellationRequested { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
IsRunning
Gets a value indicating whether the command currently has a pending operation being executed.
Declaration
public bool IsRunning { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Methods
View SourceCancel()
Communicates a request for cancelation.
Declaration
public void Cancel()
Remarks
If the underlying command is not running, or if it does not support cancelation, this method will perform no action. Note that even with a successful cancelation, the completion of the current operation might not be immediate.
CanExecute(Nullable<Object>)
Declaration
public bool CanExecute(object? parameter)
Parameters
Type | Name | Description |
---|---|---|
System.Nullable<System.Object> | parameter |
Returns
Type | Description |
---|---|
System.Boolean |
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Declaration
public void Dispose()
Execute(Nullable<Object>)
Declaration
public void Execute(object? parameter)
Parameters
Type | Name | Description |
---|---|---|
System.Nullable<System.Object> | parameter |
ExecuteAsync(Nullable<Object>)
Provides a more specific version of
Declaration
public async Task ExecuteAsync(object? parameter)
Parameters
Type | Name | Description |
---|---|---|
System.Nullable<System.Object> | parameter | The input parameter. |
Returns
Type | Description |
---|---|
Task | The |
NotifyCanExecuteChanged()
Notifies that the
Declaration
public void NotifyCanExecuteChanged()
Events
View SourceCanExecuteChanged
Declaration
public event EventHandler? CanExecuteChanged
Event Type
Type | Description |
---|---|
System.Nullable<EventHandler> |
PropertyChanged
Declaration
public event PropertyChangedEventHandler? PropertyChanged
Event Type
Type | Description |
---|---|
System.Nullable<PropertyChangedEventHandler> |