Search Results for

    Show / Hide Table of Contents

    Interface IAsyncRelayCommandCommon

    An interface to define a reusable command that encapsulates the implementation of ICommand with support for async/await command delegates and data binding (implements INotifyPropertyChanged).
    Enables instant creation of an ICommand without implementing the ICommand interface for each command.

    Inherited Members
    ICommand.CanExecute(Object)
    ICommand.Execute(Object)
    ICommand.CanExecuteChanged
    INotifyPropertyChanged.PropertyChanged
    Namespace: BionicCode.Utilities.Net
    Assembly: BionicCode.Utilities.Net.Common.dll
    Syntax
    public interface IAsyncRelayCommandCommon : ICommand, INotifyPropertyChanged

    Properties

    | Improve this Doc View Source

    CanBeCanceled

    Returns whether the command can be cancelled.

    Declaration
    bool CanBeCanceled { get; }
    Property Value
    Type Description
    Boolean

    true if cancellation is allowed. Otherwise false.

    | Improve this Doc View Source

    CurrentCancellationToken

    The currently used CancellationToken.

    Declaration
    CancellationToken CurrentCancellationToken { get; }
    Property Value
    Type Description
    CancellationToken

    A CancellationToken instance currently in use during the command execution.

    Remarks

    This property can be used to query the state of the cancellation or to register a cancellation callback by calling Register(Action).
    The instance will change for each command execution.

    | Improve this Doc View Source

    HasPending

    Return whether the command has pending executions.

    Declaration
    bool HasPending { get; }
    Property Value
    Type Description
    Boolean
    Remarks

    Only one command is executed at time. Sucessive command invocations are enqueued and run after the currently executing delegate has completed
    or was cancelled.

    | Improve this Doc View Source

    IsCancelled

    Returns whether the command's executing operation was cancelled.

    Declaration
    bool IsCancelled { get; }
    Property Value
    Type Description
    Boolean

    true if the last command execution was cancelled. Otherwise false.

    | Improve this Doc View Source

    IsExecuting

    A flag to signal if the asynchronous operation has completed.

    Declaration
    bool IsExecuting { get; }
    Property Value
    Type Description
    Boolean
    | Improve this Doc View Source

    IsPendingCancelled

    Returns whether the command's pending operations were cancelled.

    Declaration
    bool IsPendingCancelled { get; }
    Property Value
    Type Description
    Boolean

    true if the last command execution was cancelled. Otherwise false.

    | Improve this Doc View Source

    PendingCount

    Returns the number of pending command delegate executions.

    Declaration
    int PendingCount { get; }
    Property Value
    Type Description
    Int32

    Methods

    | Improve this Doc View Source

    CancelAll()

    Cancels all pending and executing commands.

    Declaration
    void CancelAll()
    Remarks

    See Cancel() for the exception behavior of this overload.

    | Improve this Doc View Source

    CancelAll(Boolean)

    Cancels all pending and executing commands.

    Declaration
    void CancelAll(bool throwOnFirstException)
    Parameters
    Type Name Description
    Boolean throwOnFirstException

    See Cancel(Boolean) for the effects of the parameter.

    Remarks

    See Cancel(Boolean) for the exception behavior of this overload.

    | Improve this Doc View Source

    CancelExecuting()

    Cancels the currently executing command.

    Declaration
    void CancelExecuting()
    Remarks

    See Cancel() for the exception behavior of this overload.

    | Improve this Doc View Source

    CancelExecuting(Boolean)

    Cancels the currently executing command.

    Declaration
    void CancelExecuting(bool throwOnFirstException)
    Parameters
    Type Name Description
    Boolean throwOnFirstException

    See Cancel(Boolean) for the effects of the parameter.

    Remarks

    See Cancel(Boolean) for the exception behavior of this overload.

    | Improve this Doc View Source

    CancelPending()

    Cancels all pending command executions.

    Declaration
    void CancelPending()
    Remarks

    See Cancel() for the exception behavior of this overload.

    | Improve this Doc View Source

    CancelPending(Boolean)

    Cancels all pending command executions.

    Declaration
    void CancelPending(bool throwOnFirstException)
    Parameters
    Type Name Description
    Boolean throwOnFirstException

    See Cancel(Boolean) for the effects of the parameter.

    Remarks

    See Cancel(Boolean) for the exception behavior of this overload.

    | Improve this Doc View Source

    CanExecute()

    Checks if the ICommand can execute.

    Declaration
    bool CanExecute()
    Returns
    Type Description
    Boolean

    true when the ICommand can execute, otherwise false.

    | Improve this Doc View Source

    ExecuteAsync()

    Executes the AsyncRelayCommand on the current command target asynchronously.

    Declaration
    Task ExecuteAsync()
    Returns
    Type Description
    Task
    Remarks

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

    | Improve this Doc View Source

    ExecuteAsync(CancellationToken)

    Executes the AsyncRelayCommand on the current command target asynchronously.

    Declaration
    Task ExecuteAsync(CancellationToken cancellationToken)
    Parameters
    Type Name Description
    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.

    Only one command is executed at time. Sucessive command invocations are enqueued and run after the currently executing delegate has completed
    or was cancelled. Query HasPending to know if the command has pending delegate executions and PendingCount to knwo the number of pending delegate executions.

    Exceptions
    Type Condition
    OperationCanceledException

    If executing command delegate was cancelled.

    | Improve this Doc View Source

    ExecuteAsync(TimeSpan)

    Executes the AsyncRelayCommand on the current command target asynchronously.

    Declaration
    Task ExecuteAsync(TimeSpan timeout)
    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.

    Returns
    Type Description
    Task
    Remarks

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

    Only one command is executed at time. Sucessive command invocations are enqueued and run after the currently executing delegate has completed
    or was cancelled. Query HasPending to know if the command has pending delegate executions and PendingCount to knwo the number of pending delegate executions.

    Exceptions
    Type Condition
    OperationCanceledException

    If the executing command delegate was cancelled.

    | Improve this Doc View Source

    ExecuteAsync(TimeSpan, CancellationToken)

    Executes the AsyncRelayCommand on the current command target asynchronously.

    Declaration
    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
    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

    InvalidateCommand()

    Raises the CanExecuteChanged event of this particular command only.

    Declaration
    void InvalidateCommand()

    Extension Methods

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