public static class ReactiveCommandExecutionExtensions Runs a ReactiveUI command from hand-written code the way a generated Bridge call runs it.
Methods
RunAsync
public static Task RunAsync<TInput, TResult>(this IReactiveCommand<TInput, TResult> command, TInput input, CancellationToken cancellationToken = default) Executes command with input and completes when the execution completes, after zero or more values, as a generated Bridge call of a command without a result does. A command that produces no value completes normally; the values are not returned.
Type parameters
TInputThe command's input type.
TResultThe command's output type.
Parameters
commandThe command.
inputThe command's input.
cancellationTokenCancels and disposes the execution.
Returns
A task that completes when the execution completes, fails with its exception, or is cancelled.
Exceptions
ArgumentNullExceptioncommandisnull.
Remarks
Use it in hand-written code that runs a command on behalf of a Bridge call or inside a model turn, such as a wrapper command that a Bridge presents and that runs a native command whose input has no wire form, when the code handles the command's failure itself, runs outside any Bridge call, or needs completion without a value. A failure of the execution is rethrown unchanged, and Runic counts it as received by this call: it is never logged as ReactiveCommandFailed (Views event 1042), whether the caller lets it propagate, wraps it or handles it, inside or outside a Bridge call. Failures of other executions of the command that arrive while this one runs are held until it ends and are logged then, as during a Bridge call.
The execution's notifications follow the model turn that started it, as for a bridged execution. Cancelling cancellationToken disposes the execution, which cancels a token-taking CreateFromTask body, and the returned task is cancelled. A token that is already cancelled does not start it.
A plain await command.Execute(input) is enough inside a Bridge call when the exception propagates or is wrapped: the Bridge call receives it. The Views.ReactiveUI guide's "Which call to use" section compares them.