Managed Operations. Subprocesses

In this lesson, you will learn how to create a Synchronous Managed Operation with subprocesses. It is recommended that you review the Getting Started lesson before proceeding.

Each subprocess will execute the ExecuteCore method of the SimpleOperation class. The difference from the previous example is the implementation of the StartSimpleOperation_Execute method.

  • c#
  • VB

private void StartSimpleOperation_Execute(object sender, SimpleActionExecuteEventArgs e)
  var managedOperation = new ManagedOperation(this.Application) { ZoneType = ManagedOperationZoneTypes.Local, Name = "Managed operation with progress bar" };
  managedOperation.CreateSubProcess("SubProcess 1", item => new SimpleOperation(this.Application).ExecuteCore(item));
  managedOperation.CreateSubProcess("SubProcess 2", item => new SimpleOperation(this.Application).ExecuteCore(item));
  managedOperation.CreateSubProcess("SubProcess 3", item => new SimpleOperation(this.Application).ExecuteCore(item));
  managedOperation.CreateSubProcess("SubProcess 4", item => new SimpleOperation(this.Application).ExecuteCore(item));
  managedOperation.CreateSubProcess("SubProcess 5", item => new SimpleOperation(this.Application).ExecuteCore(item));
  SyncManagedOperationHelper.CreateHelper(managedOperation).InitShowViewParametersSubprocess(e.ShowViewParameters, true);

Private Sub StartSimpleOperation_Execute(ByVal sender As Object, ByVal e As SimpleActionExecuteEventArgs)
  Dim managedOperation = New ManagedOperation(Me.Application) With {.ZoneType = ManagedOperationZoneTypes.Local, .Name = "Managed operation with progress bar"}
  managedOperation.CreateSubProcess("SubProcess 1", Function(ByVal item) New SimpleOperation(Me.Application).ExecuteCore(item))
  managedOperation.CreateSubProcess("SubProcess 2", Function(ByVal item) New SimpleOperation(Me.Application).ExecuteCore(item))
  managedOperation.CreateSubProcess("SubProcess 3", Function(ByVal item) New SimpleOperation(Me.Application).ExecuteCore(item))
  managedOperation.CreateSubProcess("SubProcess 4", Function(ByVal item) New SimpleOperation(Me.Application).ExecuteCore(item))
  managedOperation.CreateSubProcess("SubProcess 5", Function(ByVal item) New SimpleOperation(Me.Application).ExecuteCore(item))
  SyncManagedOperationHelper.CreateHelper(managedOperation).InitShowViewParametersSubprocess(e.ShowViewParameters, True)
End Sub

As you can see in the code above, after the main Managed Operation was created, five subprocesses were added to it using the CreateSubProcess() method. The InitShowViewParametersSubprocess() method initializes the View to display the operation with subprocesses. When such operation is started, execution of the subprocesses is shown in a separate List View. It is possible to invoke a DetailView for any subprocess.



You can see the code used in this topic in the Operation1.cs file and SyncManagedOperationsWindowController.cs file (the SyncSub_Execute method) of the Xafari Northwind demo installed with Xafari.


By default, each created subprocess gets the next running number. However, the CreateSubProcess method allows to create subprocesses with specific numbers. Use an overloaded method for this.

managedOperation.CreateSubProcess("Subprocess with index 789", item => new SimpleOperation(this.Application).ExecuteCore(item), managedOperation.Count, 789);

Another overload allows you to create a subprocess with the index equal to the count of subprocesses:

  • example

managedOperation.CreateSubProcess("Subprocess, the index is equal to the number of subprocesses", item => new SimpleOperation(this.Application).ExecuteCore(item), managedOperation.Count);