ProgressBeginSubtask Method

Spotfire 14.3 API Reference
Starts a new determinate subtask, that is, a subtask in which the extent of the operation is known, for example that it requires x steps to be performed.

Namespace:  Spotfire.Dxp.Framework.ApplicationModel
Assembly:  Spotfire.Dxp.Framework (in Spotfire.Dxp.Framework.dll) Version: 65.0.19510.3242 (65.0.19510.3242)
Syntax

C#
public IDisposable BeginSubtask(
	string title,
	long totalSteps,
	string progressDescription
)

Parameters

title
Type: SystemString
A user-friendly representation of what the sub task performs. May not be null.
totalSteps
Type: SystemInt64
The number of steps in this operation.
progressDescription
Type: SystemString
A description of the progress of the operation. This parameters allows for two placeholders to be included. The first placeholder, if included, will be replaced with a number representing the amount of progress reported to the subtask through calls to the TryReportProgress method. The placeholders are passed in as {0} and {1}, for example "Performed {0} read operation {1}". Note that passing more than two placeholder causes an exception of type FormatException to be thrown.

This parameter may not be null.

Return Value

Type: IDisposable
An object that controls the span of the subtask. This object must be disposed in order to signal that the subtask is completed.
Exceptions

ExceptionCondition
ArgumentNullException If either title, or progressDescription is null.
ArgumentOutOfRangeException If totalSteps is negative.
FormatException If progressDescription contains more than two placeholders.
Remarks

This method provides an alternative API to the corresponding ExecuteSubtask() method. It is recommended for this method to be used when a subtask covers a loop consisting of a known number of iterations. In such cases each step of the loop reports one unit of progress to the operation, using the method TryReportProgress.
Examples

Use this method as follows:
C#
ProgressService progressService = GetService<ProgressService>();
progressService.ExecuteWithProgress("Opening File",
    delegate
    {
        // Do some work
        // ...

        using(ProgressService.CurrentProgress.BeginSubtask(
            "Sub task",
            stepCount,
            "Step {0} of {1}"))
        {
            // Perform subtask
            for (int i = 0; i < stepCount; i++)
            {
                // Do something
                // ...

                ProgressService.CurrentProgress.TryReportProgress();
                ProgressService.CurrentProgress.CheckCancel();
            }
        }

        // Do more work
        // ...
    }
Version Information

Supported in: 14.3, 14.2, 14.1, 14.0, 12.5, 12.4, 12.3, 12.2, 12.1, 12.0, 11.8
See Also

Reference