Click or drag to resize

busyIndicatorCallBack Class

This class is used to report status of time-consuming operation.
Inheritance Hierarchy
SystemObject
  BindableBase
    CADSharpTools.CorebusyIndicatorCallBack

Namespace:  CADSharpTools.Core
Assembly:  CADSharpTools.PDM (in CADSharpTools.PDM.dll) Version: 1.4.16.0 (1.4.16)
Syntax
public class busyIndicatorCallBack : BindableBase, 
	ctpICallback

The busyIndicatorCallBack type exposes the following members.

Constructors
  NameDescription
Public methodbusyIndicatorCallBack
Top
Properties
  NameDescription
Public propertyCancelRequested
Returns whether a cancel question has been initiated by the user.
Public propertyCount
Count of the total elements.
Public propertyCurrent
Index of the current element.
Public propertyIsIndeterminate
True is the operation is not deterministic, false is not.
Public propertyMessage
Message to display to the user.
Top
Methods
  NameDescription
Public methodCancel
Cancels operation.
Public methodFinish
Announces the operation is finished and fires the Finished event.
Top
Events
  NameDescription
Public eventFinished
Fires when the busy indicator action has been ended.
Top
Examples
This code examples show how to use the busy indicator while getting the references of a large assembly.
  [STAThread]
static void Main(string[] args)
    {
        // local variables 
        string vaultName = "PDM2019";
        string relativePathName = @"costing\large customer assy\2596-A0000.sldasm";
        // create pdm objects
        var vault = EdmObjectFactory.CreateVaultObject(vaultName);
        var file = EdmObjectFactory.CreateFileObjectFromRelativePath(vault, relativePathName);
        var folder = file.GetFolder();
        string localPath = file.GetLocalPath(folder.ID);
        // create document
        var doc = new Document(file.ID, folder.ID, localPath);
        // define busyIndicatorCallBack 
        var biCallback = new busyIndicatorCallBack();
        // set the progress bar to indeterminate because the number of references is unknown 
        biCallback.IsIndeterminate = true;
        // invoker will invoke time consuming method
        var biInvoker = new busyIndicatorInvoker(biCallback);
        biInvoker.InvokeAsync(() => {
            // execute timer-consuming task 
            doc.ConstructReferenceTree(vault, biCallback);
        });
        // create busy indicator window
        var biViewModel = new BusyIndicatorViewModel<busyIndicatorCallBack>(biCallback, $"Constructing  reference tree for {file.Name}...");
        biViewModel.ShowView(true);
        // get all references
        var references = doc.FlattenReferences();
        // print results 
        if (biCallback.CancelRequested)
            Console.WriteLine($"This operation has been canceled by user. Found {references.Length} references. {biViewModel.TimeElapsed}");
        else
            Console.WriteLine($"This operation has been complete. Found {references.Length} references.  {biViewModel.TimeElapsed}");
        Console.ReadLine();
    }
Preview of the busy indicator view in Windows 10:

Result:
See Also