|
![]() |
Starts a sub operation. Progress in sub op between 0 and 1 maps to fraction of remaining time in main operation. Can be nested.
Namespace: Autodesk.Navisworks.Api
Assembly: Autodesk.Navisworks.Api (in Autodesk.Navisworks.Api.dll)
Syntax
Visual Basic |
---|
Public Sub BeginSubOperation ( _ fractionOfRemainingTime As Double _ ) |
C# |
---|
public void BeginSubOperation( double fractionOfRemainingTime ) |
Visual C++ |
---|
public: void BeginSubOperation( double fractionOfRemainingTime ) |
Parameters
- fractionOfRemainingTime
- Type: System..::..Double
Fraction of remaining time this sub operation will take, between 0 and 1
Remarks
Used when an operation consists of more complicated sub operations. Allows the system to more accurately inform the user of the progress of a process. The Double value represents the percentage value, of the overall process, expected to be completed by the end of this sub operation. The (optional) String value is the text description of the sub process.
Examples

/// <summary> /// This illustrates using Sub processes within a progress bar /// </summary> private static void AdvancedProgressExample() { // Get the progress indicator Progress progress = Autodesk.Navisworks.Api.Application.BeginProgress(); double stage = 0.0; //------------------------------------------------------------------ //Start the first stage //------------------------------------------------------------------ progress.BeginSubOperation(0.33, "Stage 1"); //This takes up 33% of the remaining time for the total operation System.Threading.Thread.Sleep(1000); stage = DoWork(progress, stage, 0.33, 0.01); //End sub operation, pass true to tidy up the progress bar progress.EndSubOperation(true); //------------------------------------------------------------------ //Begin second stage, update main percentage //------------------------------------------------------------------ progress.BeginSubOperation(0.5, "Stage 2"); //This takes up 50% of the remaining time, ( 34% of total time) stage = DoWork(progress, stage, 0.67, 0.01); //End sub operation, pass true to tidy up the progress bar progress.EndSubOperation(true); //------------------------------------------------------------------ //Final stage, update main percentage //------------------------------------------------------------------ progress.BeginSubOperation(1.0, "Stage 3"); //This takes up all the remaining time. (33% of the total time stage = DoWork(progress, stage, 1.0, 0.01); //End sub operation, pass true to tidy up the progress bar progress.EndSubOperation(true); //------------------------------------------------------------------ // End progress bar lifetime Autodesk.Navisworks.Api.Application.EndProgress(); } /// <summary> /// Does some arbitrary work /// </summary> /// <param name="progress">the progress object passed from the API</param> /// <param name="stage">the current overall position</param> /// <param name="maxValue">the max value for this chunk of work</param> /// <param name="increment">what to increment the position by</param> /// <returns></returns> private static double DoWork(Progress progress, double stage, double maxValue, double increment) { for (; stage < maxValue; stage += increment) { //Update progress bar progress.Update(stage); System.Threading.Thread.Sleep(100); } return stage; }
Exceptions
Exception | Condition |
---|---|
System..::..ObjectDisposedException | Object has been Disposed |
System..::..NotSupportedException | Object is Read-Only |