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
System.Object
  BionicCode.Utilities.Net.Framework.Wpf.Generic.AsyncRelayCommand<Object>
    BionicCode.Utilities.Net.Framework.Wpf.AsyncRelayCommand

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(Action<Object>)
Initializes a new instance of the AsyncRelayCommand class
Public methodAsyncRelayCommand(Func<Task>)
Creates a new parameterless asynchronous command that can always execute (CanExecute() will always return true).
Public methodAsyncRelayCommand(Func<Object, Task>)
Initializes a new instance of the AsyncRelayCommand class
Public methodAsyncRelayCommand(Action, Func<Boolean>)
Creates a new parameterless command.
Public methodAsyncRelayCommand(Action<Object>, Predicate<Object>)
Initializes a new instance of the AsyncRelayCommand class
Public methodAsyncRelayCommand(Func<Task>, Func<Boolean>)
Creates a parameterless new asynchronous command.
Public methodAsyncRelayCommand(Func<Object, Task>, Predicate<Object>)
Initializes a new instance of the AsyncRelayCommand class
Top
Properties
Methods
  NameDescription
Public methodCanExecute()
Determines whether this AsyncRelayCommand can execute.
(Inherited from AsyncRelayCommand<TParam>.)
Public methodCanExecute(TParam)
Determines whether this AsyncRelayCommand can execute.
(Inherited from AsyncRelayCommand<TParam>.)
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 AsyncRelayCommand<TParam>.)
Public methodExecuteAsync(CancellationToken)
Executes the AsyncRelayCommand on the current command target asynchronously.
(Inherited from AsyncRelayCommand<TParam>.)
Public methodExecuteAsync(TParam)
Executes the AsyncRelayCommand on the current command target asynchronously.
(Inherited from AsyncRelayCommand<TParam>.)
Public methodExecuteAsync(TParam, CancellationToken)
Executes the AsyncRelayCommand on the current command target asynchronously.
(Inherited from AsyncRelayCommand<TParam>.)
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 AsyncRelayCommand<TParam>.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Protected methodOnCanExecuteChanged
Raises the CanExecuteChanged event.
(Inherited from AsyncRelayCommand<TParam>.)
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 methodICommand.CanExecute
Explicit ICommand implementation. Determines whether this AsyncRelayCommand can execute.
(Inherited from AsyncRelayCommand<TParam>.)
Explicit interface implementationPrivate methodICommand.Execute
Explicit ICommand implementation. Executes the AsyncRelayCommand on the current command target.
(Inherited from AsyncRelayCommand<TParam>.)
Explicit interface implementationPrivate methodIAsyncRelayCommand.ExecuteAsync(Object)
Asynchronously executes the AsyncRelayCommand on the current command target.
(Inherited from AsyncRelayCommand<TParam>.)
Explicit interface implementationPrivate methodIAsyncRelayCommand.ExecuteAsync(Object, CancellationToken)
Asynchronously executes the AsyncRelayCommand on the current command target.
(Inherited from AsyncRelayCommand<TParam>.)
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