Managed Business Operation Class
This interface declares two methods: ExecuteManaged() and RollbackManaged(). It also declares the Process property that is an object of the Managed Operation which controls and monitors the execution of a Business Operation. The mentioned methods start the BO in the managed context. Being called, these methods initialize the Process property with an instance of the created Managed Operation.
The code of the Managed Business Operation will be executed in a separate thread. The developer must be aware of this fact when coding application logic.
When implementing a managed BO class, it is recommended to inherit from the BusinessOperationManagedBase base class. The class implements two methods: ExecuteManaged() and RollbackManaged(). It also provides two protected virtual methods: CreateManagedOperation() and CreateManagedOperationStub().
The CreateManagedOperation() method creates an instance of the ManagedOperation class. The BO is executed under the control of this instance. To customize the Managed Operation, the developer overrides this method in the code of the Business Operation class.
The CreateManagedOperationStub() method creates an instance of the ManagedOperationStub class. ManagedOperationStub is a dummy class of the Managed Operation. It allows to call the Process property in the code even if the property is not initialized. To start a managed BO asynchronously, use the Execute() method instead of the ExecuteManaged() method. The access to the Process property can be required in the code of the BO Implementation class. The ManagedOperationStub() class is intended to avoid multiple checks (e.g. as in the following code):
public void Execute()
if (Process != null)
Public Sub Execute()
If Process IsNot Nothing Then
The base class implementation of the Process property is designed specially to keep this property initialized all the time.
If the described behavior does not suit the developer's needs, it is possible to override the CreateManagedOperationStub() method in one's own code (e.g., make it return "null").
Other aspect of developing a managed BO are not different from the procedure described in the previous topic.