Search Results for

    Show / Hide Table of Contents

    Class AsyncRelayCommandCommon<TParam>

    A reusable command that encapsulates the implementation of ICommand with support for async/await command delegates.
    Enables instant creation of an ICommand without implementing the ICommand interface for each command. The AsyncRelayCommandCommon<TParam> accepts asynchronous command handlers and supports data bindng to properties like IsExecuting by implementing INotifyPropertyChanged.
    Call and await the ExecuteAsync(TParam) method or one of its overloads to execute the command explicitly asynchronously. ICommand

    Inheritance
    Object
    AsyncRelayCommandCommon
    AsyncRelayCommandCommon<TParam>
    AsyncRelayCommand<TParam>
    Implements
    IAsyncRelayCommandCommon<TParam>
    IAsyncRelayCommandCommon
    ICommand
    INotifyPropertyChanged
    Inherited Members
    AsyncRelayCommandCommon.MaxThreads
    AsyncRelayCommandCommon.IsExecuting
    AsyncRelayCommandCommon.IsPendingCancelled
    AsyncRelayCommandCommon.IsCancelled
    AsyncRelayCommandCommon.HasPending
    AsyncRelayCommandCommon.PendingCount
    AsyncRelayCommandCommon.CanBeCanceled
    AsyncRelayCommandCommon.CurrentCancellationToken
    AsyncRelayCommandCommon.PropertyChanged
    AsyncRelayCommandCommon.ExecuteAsyncNoParamDelegate
    AsyncRelayCommandCommon.ExecuteCancellableAsyncNoParamDelegate
    AsyncRelayCommandCommon.ExecuteNoParamDelegate
    AsyncRelayCommandCommon.ExecuteCancellableNoParamDelegate
    AsyncRelayCommandCommon.CanExecuteNoParamDelegate
    AsyncRelayCommandCommon.CanExecuteChanged
    AsyncRelayCommandCommon.ExecuteAsync()
    AsyncRelayCommandCommon.ExecuteAsync(CancellationToken)
    AsyncRelayCommandCommon.ExecuteAsync(TimeSpan)
    AsyncRelayCommandCommon.TryExecuteNoParamCommand()
    AsyncRelayCommandCommon.CancelExecuting()
    AsyncRelayCommandCommon.CancelExecuting(Boolean)
    AsyncRelayCommandCommon.CancelPending()
    AsyncRelayCommandCommon.CancelPending(Boolean)
    AsyncRelayCommandCommon.CancelAll()
    AsyncRelayCommandCommon.CancelAll(Boolean)
    AsyncRelayCommandCommon.InvalidateCommand()
    AsyncRelayCommandCommon.OnCanExecuteChanged()
    AsyncRelayCommandCommon.OnPropertyChanged(String)
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Object.ReferenceEquals(Object, Object)
    Object.ToString()
    Namespace: BionicCode.Utilities.Net
    Assembly: BionicCode.Utilities.Net.Common.dll
    Syntax
    public abstract class AsyncRelayCommandCommon<TParam> : AsyncRelayCommandCommon, IAsyncRelayCommandCommon<TParam>, IAsyncRelayCommandCommon, ICommand, INotifyPropertyChanged
    Type Parameters
    Name Description
    TParam
    Remarks

    AsyncRelayCommandCommon implements ICommand. In case the AsyncRelayCommandCommon<TParam> is executed explicitly, especially with an asynchronous command handler registered, it is highly recommended to invoke the awaitable ExecuteAsync() or its overloads instead.

    Constructors

    | Improve this Doc View Source

    AsyncRelayCommandCommon()

    Constructor.

    Declaration
    protected AsyncRelayCommandCommon()
    | Improve this Doc View Source

    AsyncRelayCommandCommon(Action)

    Creates a new parameterless synchronous command that can always execute (CanExecute() will always return true).

    Declaration
    protected AsyncRelayCommandCommon(Action executeNoParam)
    Parameters
    Type Name Description
    Action executeNoParam

    The awaitable execution handler.

    | Improve this Doc View Source

    AsyncRelayCommandCommon(Action, Func<Boolean>)

    Creates a new parameterless synchronous command.

    Declaration
    protected AsyncRelayCommandCommon(Action executeNoParam, Func<bool> canExecuteNoParam)
    Parameters
    Type Name Description
    Action executeNoParam

    The execution handler.

    Func<Boolean> canExecuteNoParam

    The execution status handler.

    | Improve this Doc View Source

    AsyncRelayCommandCommon(Action<TParam, CancellationToken>)

    Creates a new synchronous command that can always execute (CanExecute() will always return true)
    and accepts a command parameter of type TParam
    and supports cancellation.

    Declaration
    protected AsyncRelayCommandCommon(Action<TParam, CancellationToken> execute)
    Parameters
    Type Name Description
    Action<TParam, CancellationToken> execute

    The awaitable execution handler.

    | Improve this Doc View Source

    AsyncRelayCommandCommon(Action<TParam, CancellationToken>, Predicate<TParam>)

    Creates a new synchronous command that supports cancellation adn accepts a command parameter of type TParam.

    Declaration
    protected AsyncRelayCommandCommon(Action<TParam, CancellationToken> executeAsync, Predicate<TParam> canExecute)
    Parameters
    Type Name Description
    Action<TParam, CancellationToken> executeAsync

    The awaitable execution handler.

    Predicate<TParam> canExecute

    The can execute handler.

    | Improve this Doc View Source

    AsyncRelayCommandCommon(Action<TParam>)

    Creates a new synchronous command that can always execute (CanExecute() will always return true)
    and accepts a command parameter of type TParam.

    Declaration
    protected AsyncRelayCommandCommon(Action<TParam> execute)
    Parameters
    Type Name Description
    Action<TParam> execute

    The awaitable execution handler.

    | Improve this Doc View Source

    AsyncRelayCommandCommon(Action<TParam>, Predicate<TParam>)

    Creates a new synchronous command that accepts a command parameter of type TParam.

    Declaration
    protected AsyncRelayCommandCommon(Action<TParam> execute, Predicate<TParam> canExecute)
    Parameters
    Type Name Description
    Action<TParam> execute

    The execution handler.

    Predicate<TParam> canExecute

    The execution status handler.

    | Improve this Doc View Source

    AsyncRelayCommandCommon(Action<CancellationToken>)

    Creates a new parameterless synchronous command that can always execute (CanExecute() will always return true)
    and supports cancellation.

    Declaration
    protected AsyncRelayCommandCommon(Action<CancellationToken> executeNoParam)
    Parameters
    Type Name Description
    Action<CancellationToken> executeNoParam

    The awaitable execution handler.

    | Improve this Doc View Source

    AsyncRelayCommandCommon(Action<CancellationToken>, Func<Boolean>)

    Creates a new parameterless synchronous command that supports cancellation.

    Declaration
    protected AsyncRelayCommandCommon(Action<CancellationToken> executeAsync, Func<bool> canExecute)
    Parameters
    Type Name Description
    Action<CancellationToken> executeAsync

    The awaitable execution handler.

    Func<Boolean> canExecute

    The can execute handler.

    | Improve this Doc View Source

    AsyncRelayCommandCommon(Func<TParam, CancellationToken, Task>)

    Creates a new asynchronous command that can always execute (CanExecute() will always return true)
    and that accepts a command parameter of type TParam
    and supports cancellation.

    Declaration
    protected AsyncRelayCommandCommon(Func<TParam, CancellationToken, Task> executeAsync)
    Parameters
    Type Name Description
    Func<TParam, CancellationToken, Task> executeAsync

    The awaitable execution handler.

    | Improve this Doc View Source

    AsyncRelayCommandCommon(Func<TParam, CancellationToken, Task>, Predicate<TParam>)

    Creates a new asynchronous command that supports cancellation and accepts a command parameter of TParam.

    Declaration
    protected AsyncRelayCommandCommon(Func<TParam, CancellationToken, Task> executeAsync, Predicate<TParam> canExecute)
    Parameters
    Type Name Description
    Func<TParam, CancellationToken, Task> executeAsync

    The awaitable execution handler.

    Predicate<TParam> canExecute

    The can execute handler.

    | Improve this Doc View Source

    AsyncRelayCommandCommon(Func<TParam, Task>)

    Creates a new asynchronous command that can always execute (CanExecute() will always return true)
    and that accepts a command parameter of type TParam.

    Declaration
    protected AsyncRelayCommandCommon(Func<TParam, Task> executeAsync)
    Parameters
    Type Name Description
    Func<TParam, Task> executeAsync

    The awaitable execution handler.

    | Improve this Doc View Source

    AsyncRelayCommandCommon(Func<TParam, Task>, Predicate<TParam>)

    Creates a new asynchronous command that accepts a command parameter of type TParam.

    Declaration
    protected AsyncRelayCommandCommon(Func<TParam, Task> executeAsync, Predicate<TParam> canExecute)
    Parameters
    Type Name Description
    Func<TParam, Task> executeAsync

    The awaitable execution handler.

    Predicate<TParam> canExecute

    The can execute handler.

    | Improve this Doc View Source

    AsyncRelayCommandCommon(Func<CancellationToken, Task>)

    Creates a new parameterless asynchronous command that can always execute (CanExecute() will always return true)
    and supports cancellation.

    Declaration
    protected AsyncRelayCommandCommon(Func<CancellationToken, Task> executeAsyncNoParam)
    Parameters
    Type Name Description
    Func<CancellationToken, Task> executeAsyncNoParam

    The awaitable execution handler.

    | Improve this Doc View Source

    AsyncRelayCommandCommon(Func<CancellationToken, Task>, Func<Boolean>)

    Creates a new parameterless asynchronous command that supports cancellation and does not take a command parameter.

    Declaration
    protected AsyncRelayCommandCommon(Func<CancellationToken, Task> executeAsync, Func<bool> canExecute)
    Parameters
    Type Name Description
    Func<CancellationToken, Task> executeAsync

    The awaitable execution handler.

    Func<Boolean> canExecute

    The can execute handler.

    | Improve this Doc View Source

    AsyncRelayCommandCommon(Func<Task>)

    Creates a new parameterless asynchronous command that can always execute (CanExecute() will always return true).

    Declaration
    protected AsyncRelayCommandCommon(Func<Task> executeAsyncNoParam)
    Parameters
    Type Name Description
    Func<Task> executeAsyncNoParam

    The awaitable execution handler.

    | Improve this Doc View Source

    AsyncRelayCommandCommon(Func<Task>, Func<Boolean>)

    Creates a parameterless new asynchronous command.

    Declaration
    protected AsyncRelayCommandCommon(Func<Task> executeAsyncNoParam, Func<bool> canExecuteNoParam)
    Parameters
    Type Name Description
    Func<Task> executeAsyncNoParam

    The awaitable execution handler.

    Func<Boolean> canExecuteNoParam

    The execution status handler.

    Properties

    | Improve this Doc View Source

    CanExecuteDelegate

    The registered CanExecute delegate that accepts a parameter of TParam.

    Declaration
    protected Func<TParam, bool> CanExecuteDelegate { get; }
    Property Value
    Type Description
    Func<TParam, Boolean>

    true if the command can execute, otherwise false.

    | Improve this Doc View Source

    ExecuteAsyncDelegate

    The registered async execute delegate that accepts a parameter of TParam.

    Declaration
    protected Func<TParam, Task> ExecuteAsyncDelegate { get; }
    Property Value
    Type Description
    Func<TParam, Task>

    A delegate that takes a command parameter of TParam and returns a Task.

    | Improve this Doc View Source

    ExecuteCancellableAsyncDelegate

    The registered async execute delegate that supports cancellation and accepts a parameter of TParam.

    Declaration
    protected Func<TParam, CancellationToken, Task> ExecuteCancellableAsyncDelegate { get; }
    Property Value
    Type Description
    Func<TParam, CancellationToken, Task>

    A delegate that supports cancellation and takes a command parameter of TParam and returns a Task.

    | Improve this Doc View Source

    ExecuteCancellableDelegate

    The registered execute delegate that accepts a parameter of TParam.

    Declaration
    protected Action<TParam, CancellationToken> ExecuteCancellableDelegate { get; }
    Property Value
    Type Description
    Action<TParam, CancellationToken>

    A delegate that suppoprts cancellation and takes a command parameter of TParam and returns a Task.

    | Improve this Doc View Source

    ExecuteDelegate

    The registered execute delegate that accepts a parameter of TParam.

    Declaration
    protected Action<TParam> ExecuteDelegate { get; }
    Property Value
    Type Description
    Action<TParam>

    A delegate that takes no parameter and returns a Task.

    Methods

    | Improve this Doc View Source

    CanExecute()

    Determines whether this AsyncRelayCommandCommon can execute.

    Declaration
    public bool CanExecute()
    Returns
    Type Description
    Boolean

    true if this command can be executed, otherwise false.

    | Improve this Doc View Source

    CanExecute(TParam)

    Determines whether this AsyncRelayCommandCommon can execute.

    Declaration
    public bool CanExecute(TParam parameter)
    Parameters
    Type Name Description
    TParam parameter

    Data used by the command.

    Returns
    Type Description
    Boolean

    true if this command can be executed, otherwise false.

    | Improve this Doc View Source

    ExecuteAsync(TParam)

    Executes the AsyncRelayCommand on the current command target asynchronously.

    Declaration
    public async Task ExecuteAsync(TParam parameter)
    Parameters
    Type Name Description
    TParam parameter

    Data used by the command. If the command does not require data to be passed, this object can be set to null.

    Returns
    Type Description
    Task
    Remarks

    If the registered command handler is asynchronous (awaitable), then the execution is asynchronous otherwise the delegate is executed synchronously.

    Exceptions
    Type Condition
    OperationCanceledException

    If the executing command delegate was cancelled.

    | Improve this Doc View Source

    ExecuteAsync(TParam, CancellationToken)

    Executes the AsyncRelayCommand on the current command target asynchronously.

    Declaration
    public async Task ExecuteAsync(TParam parameter, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    TParam parameter

    Data used by the command. If the command does not require data to be passed, this object can be set to null.

    CancellationToken cancellationToken

    An instance of CancellationToken to cancel the executing command delegate.

    Returns
    Type Description
    Task
    Remarks

    If the registered command handler is asynchronous (awaitable), then the execution is asynchronous otherwise the delegate is executed synchronously.

    Exceptions
    Type Condition
    OperationCanceledException

    If the executing command delegate was cancelled.

    | Improve this Doc View Source

    ExecuteAsync(TParam, TimeSpan)

    Executes the AsyncRelayCommand on the current command target asynchronously.

    Declaration
    public async Task ExecuteAsync(TParam parameter, TimeSpan timeout)
    Parameters
    Type Name Description
    TParam parameter

    Data used by the command. If the command does not require data to be passed, this object can be set to null.

    TimeSpan timeout

    A TimeSpan to specify the timeout of the operation.
    A value of InfiniteTimeSpan (or a TimeSpan that represents -1) will specifiy an infinite time out.
    A value of Zero will cancel the operation immediately.

    Returns
    Type Description
    Task
    Remarks

    If the registered command handler is asynchronous (awaitable), then the execution is asynchronous otherwise the delegate is executed synchronously.

    Exceptions
    Type Condition
    OperationCanceledException

    If the executing command delegate was cancelled.

    ArgumentOutOfRangeException

    timeout>>.TotalMilliseconds is less than -1 or greater than MaxValue (or MaxValue - 1 on some versions of .NET).
    Note that this upper bound is more restrictive than MaxValue.

    | Improve this Doc View Source

    ExecuteAsync(TParam, TimeSpan, CancellationToken)

    Executes the AsyncRelayCommand on the current command target asynchronously.

    Declaration
    public async Task ExecuteAsync(TParam parameter, TimeSpan timeout, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    TParam parameter

    Data used by the command. If the command does not require data to be passed, this object can be set to null.

    TimeSpan timeout

    A TimeSpan to specify the timeout of the operation.
    A value of InfiniteTimeSpan (or a TimeSpan that represents -1) will specifiy an infinite time out.
    A value of Zero will cancel the operation immediately.

    CancellationToken cancellationToken

    An instance of CancellationToken to cancel the executing command delegate.

    Returns
    Type Description
    Task
    Remarks

    If the registered command handler is asynchronous (awaitable), then the execution is asynchronous otherwise the delegate is executed synchronously.

    Exceptions
    Type Condition
    OperationCanceledException

    If the executing command delegate was cancelled.

    ArgumentOutOfRangeException

    timeout>>.TotalMilliseconds is less than -1 or greater than MaxValue (or MaxValue - 1 on some versions of .NET). Note that this upper bound is more restrictive than MaxValue.

    | Improve this Doc View Source

    ExecuteAsync(TimeSpan, CancellationToken)

    Executes the AsyncRelayCommand on the current command target asynchronously.

    Declaration
    public override async Task ExecuteAsync(TimeSpan timeout, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    TimeSpan timeout

    A TimeSpan to specify the timeout of the operation.
    A value of InfiniteTimeSpan (or a TimeSpan that represents -1) will specifiy an infinite time out.
    A value of Zero will cancel the operation immediately.

    CancellationToken cancellationToken

    An instance of CancellationToken to cancel the executing command delegate.

    Returns
    Type Description
    Task
    Overrides
    AsyncRelayCommandCommon.ExecuteAsync(TimeSpan, CancellationToken)
    Remarks

    If the registered command handler is asynchronous (awaitable), then the execution is asynchronous otherwise the delegate is executed synchronously.

    Exceptions
    Type Condition
    OperationCanceledException

    If the executing command delegate was cancelled.

    ArgumentOutOfRangeException

    timeout>>.TotalMilliseconds is less than -1 or greater than MaxValue (or MaxValue - 1 on some versions of .NET). Note that this upper bound is more restrictive than MaxValue.

    Explicit Interface Implementations

    | Improve this Doc View Source

    ICommand.CanExecute(Object)

    Declaration
    bool ICommand.CanExecute(object parameter)
    Parameters
    Type Name Description
    Object parameter
    Returns
    Type Description
    Boolean
    | Improve this Doc View Source

    ICommand.Execute(Object)

    Declaration
    async void ICommand.Execute(object parameter)
    Parameters
    Type Name Description
    Object parameter

    Implements

    IAsyncRelayCommandCommon<TParam>
    IAsyncRelayCommandCommon
    ICommand
    INotifyPropertyChanged

    Extension Methods

    HelperExtensionsCommon.ToDictionary(Object)
    HelperExtensionsCommon.ToFlatDictionary(Object)
    • Improve this Doc
    • View Source
    In This Article
    Back to top Generated by DocFX