RunicOperationProgress class

Namespace Runic.Application.Views in Runic.Application.Views 0.23.0

public static class RunicOperationProgress

Reports the progress of the operation whose command runs on the current asynchronous flow (Views protocol 4, "Progress").

Remarks

A command started as an operation (start{Command}() in the generated client) runs in the operation's flow, so it can report how far it got without changing its signature. Pages that watch the operation receive the progress as progress on its running status, at most every 100 ms. Outside an operation, including a command invoked through its ordinary awaited call, reporting does nothing.

An asynchronous command can instead take the progress as its parameter, the .NET pattern: a CommunityToolkit [RelayCommand] method Task ImportAsync(IProgress<double> progress, CancellationToken token), or a ReactiveUI ReactiveCommand<IProgress<double>, TResult>. The Bridge passes it RunicOperationProgress.Current, so the page sends no input for the parameter, and its generated client calls the command without one.

Properties

Current

public static IProgress<double> Current { get; }

Gets a progress reporter bound to the operation whose command runs on the current asynchronous flow, as RunicOperationProgress.Report reports. Outside an operation it is a reporter that does nothing.

Remarks

The reporter keeps reporting to that operation from any thread or flow, such as a library method that takes an IProgress and reports from a worker thread, until the operation ends; later reports are ignored. It reports synchronously, without Progress's posting to a synchronization context.

Methods

Report

public static void Report(double fraction)

Reports the fraction of the operation's work that is done.

Parameters

fraction

A number from 0 to 1. Values outside the range are clamped to it; Double.NaN is ignored.