Progress Class

Spotfire 14.3 API Reference
Represents progress of an operation that has been started through a call to the ExecuteWithProgress(String, String, ProgressOperation).
Inheritance Hierarchy

SystemObject
  Spotfire.Dxp.Framework.ApplicationModelProgress

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 abstract class Progress

The Progress type exposes the following members.

Methods

  NameDescription
Public methodCode exampleBeginSubtask
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.
Public methodCheckCancel
Checks if the current progress operation has been canceled by the user and if so, throws a ProgressCanceledException.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public methodCode exampleExecuteSubtask(String)
Marks the start of a new subtask.
Public methodCode exampleExecuteSubtask(String, ProgressOperation)
Starts a new continuous subtask, that is, a subtask in which the extent of the operation is either not known or not of interest.
Public methodCode exampleExecuteSubtask(String, Int64, String, ProgressOperation)
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.
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public methodTryReportProgress
Reports one unit of progress to the currently executing subtask.
Public methodTryReportProgress(Int64)
Report one or more steps of progress to the currently executing subtask.
Top
Remarks

Within the extent of a progress, sub tasks (that is, sub operations) may be executed. Sub tasks can be nested in a way that forms a tree where the progress object is the root node. When executed, each node in this tree is visited depth first, and the operation associated with each node is executed. Sub tasks are executed with one of the ExecuteSubtask method in this class.

It is possible to access the currently ongoing progress object through a call to CurrentProgress. Using this object, new sub tasks can be created, progress can be reported, and one can check for cancellations of the progress. In cases where no progress has been created through a call to ExecuteWithProgress(String, String, ProgressOperation), a default progress object is returned using which operations can be executed. Note, however, that no progress dialog is associated with this default progress object.

It is important to note that all code executed with progress is executed within a worker thread. Unhandled exceptions that may occur in this thread, are re-thrown in the main application thread wrapped in a TargetInvocationException.

This class cannot be extended through inheritance.

Examples

The following example shows an operation containing a subtask being executed with progress.
C#
ProgressService progressService = GetService<ProgressService>();
progressService.ExecuteWithProgress("Opening File",
    delegate
    {
        // Do some work
        // ...

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

                        ProgressService.CurrentProgress.TryReportProgress();
                        ProgressService.CurrentProgress.CheckCancel();
                    }
                }
                catch (ProgressOperationCanceledException)
                {
                    // Handle exception
                }
                finally
                {
                    // Perform Cleanup
                }
            });

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