Click or drag to resize

AsyncRelayCommand Class

A reusable command that encapsulates the implementation of ICommand with support for async/await. Enables instant creation of an ICommand without implementing the ICommand interface for each command. The AsyncRelayCommand accepts asynchronous command handlers.
Inheritance Hierarchy
SystemObject
  BionicCode.Utilities.Net.Framework.Wpf.GenericAsyncRelayCommandObject
    BionicCode.Utilities.Net.Framework.WpfAsyncRelayCommand

Namespace:  BionicCode.Utilities.Net.Framework.Wpf
Assembly:  BionicCode.Utilities.Net.Framework.Wpf (in BionicCode.Utilities.Net.Framework.Wpf.dll) Version: 1.0.3.0 (1.0.0.0)
Syntax
public class AsyncRelayCommand : AsyncRelayCommand<Object>

The AsyncRelayCommand type exposes the following members.

Constructors
  NameDescription
Public methodAsyncRelayCommand(Action)
Creates a new parameterless command that can always execute (CanExecute will always return true).
Public methodAsyncRelayCommand(ActionObject)
Initializes a new instance of the AsyncRelayCommand class
Public methodAsyncRelayCommand(FuncTask)
Creates a new parameterless asynchronous command that can always execute (CanExecute will always return true).
Public methodAsyncRelayCommand(FuncObject, Task)
Initializes a new instance of the AsyncRelayCommand class
Public methodAsyncRelayCommand(Action, FuncBoolean)
Creates a new parameterless command.
Public methodAsyncRelayCommand(ActionObject, PredicateObject)
Initializes a new instance of the AsyncRelayCommand class
Public methodAsyncRelayCommand(FuncTask, FuncBoolean)
Creates a parameterless new asynchronous command.
Public methodAsyncRelayCommand(FuncObject, Task, PredicateObject)
Initializes a new instance of the AsyncRelayCommand class
Top
Properties
Methods
  NameDescription
Public methodCanExecute
Determines whether this AsyncRelayCommand can execute.
(Inherited from AsyncRelayCommandTParam.)
Public methodCanExecute(TParam)
Determines whether this AsyncRelayCommand can execute.
(Inherited from AsyncRelayCommandTParam.)
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public methodExecuteAsync
Executes the AsyncRelayCommand on the current command target asynchronously.
(Inherited from AsyncRelayCommandTParam.)
Public methodExecuteAsync(CancellationToken)
Executes the AsyncRelayCommand on the current command target asynchronously.
(Inherited from AsyncRelayCommandTParam.)
Public methodExecuteAsync(TParam)
Executes the AsyncRelayCommand on the current command target asynchronously.
(Inherited from AsyncRelayCommandTParam.)
Public methodExecuteAsync(TParam, CancellationToken)
Executes the AsyncRelayCommand on the current command target asynchronously.
(Inherited from AsyncRelayCommandTParam.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodInvalidateCommand
Extends ICommand to allow asynchronous command execution, where the accepted parameter of the ExecuteAsync(TParam) and CanExecute is strongly typed to eliminate type casting inside the registered callbacks.
(Inherited from AsyncRelayCommandTParam.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Protected methodOnCanExecuteChanged
Raises the CanExecuteChanged event.
(Inherited from AsyncRelayCommandTParam.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Events
Fields
Extension Methods
Explicit Interface Implementations
  NameDescription
Explicit interface implementationPrivate methodICommandCanExecute
Explicit ICommand implementation. Determines whether this AsyncRelayCommand can execute.
(Inherited from AsyncRelayCommandTParam.)
Explicit interface implementationPrivate methodICommandExecute
Explicit ICommand implementation. Executes the AsyncRelayCommand on the current command target.
(Inherited from AsyncRelayCommandTParam.)
Explicit interface implementationPrivate methodIAsyncRelayCommandExecuteAsync(Object)
Asynchronously executes the AsyncRelayCommand on the current command target.
(Inherited from AsyncRelayCommandTParam.)
Explicit interface implementationPrivate methodIAsyncRelayCommandExecuteAsync(Object, CancellationToken)
Asynchronously executes the AsyncRelayCommand on the current command target.
(Inherited from AsyncRelayCommandTParam.)
Top
Remarks
AsyncRelayCommand implements ICommand. In case Execute(Object) is invoked with a registered asynchronous command handler (e.g., by an implementation of ICommandSource), the handler is executed asynchronously. In case the AsyncRelayCommand is executed explicitly, especially with an asynchronous command handler registered, it is highly recommended to invoke the awaitable ExecuteAsync(object) or one of its overloads instead!
See Also
https://github.com/BionicCode/BionicCode.Net/blob/master/README.md