In our previous topic, we learned that how can we access workflow process definitions in a workflow package using Aspose.Workflow . In this topic, we will see that how can we create or start a workflow process instance. The difference between a Process definition and its instance is the same as that of a Class and and its instance. So, it's the process instance that executes and performs some useful operations of the workflow. Whenever, it is required to perform some specific task then process instance is created to accomplish that task.
Please follow the steps below to start a workflow process instance after logging on to the Aspose.Workflow engine:
- Create a reference of IInstanceAdmin interface using InstanceAdmin property of IEngine object
- Call CreateProcessInstance method of IInstanceAdmin object. Pass the IDs of your desired package and the underlying process whose instance is to be created. This method will create the specified process instance and then return a reference to that instance, which can be used by users to track the information about that process instance at any time while its running.
Please review the example given below for the demonstration purposes.
Example:
[C#]
//Instantiate an object of EngineManager
EngineManager manager = EngineManager.Instance;
//Configure the EngineManager object
manager.Configure();
//Create an object of IEngine interface
IEngine engine = manager.Engine;
//Login to the Aspose.Workflow engine
engine.Login("aspose","aspose");
//Create an instance of IInstanceAdmin interface
IInstanceAdmin instanceAdmin = engine.InstanceAdmin;
//Starting an instance of the process whose ID is "DemoProcess"
IProcessInstance instance = instanceAdmin.CreateProcessInstance("ContractWorkflow",
"DemoProcess");
[VB.NET]
'Instantiate an object of EngineManager
Dim manager As EngineManager = EngineManager.Instance
'Configure the EngineManager object
manager.Configure()
'Create an object of IEngine interface
Dim engine As IEngine = manager.Engine
'Login to the Aspose.Workflow engine
engine.Login("aspose","aspose")
'Create an instance of IInstanceAdmin interface
Dim instanceAdmin As IInstanceAdmin = engine.InstanceAdmin
'Starting an instance of the process whose ID is "DemoProcess"
Dim instance As IProcessInstance = instanceAdmin.CreateProcessInstance("ContractWorkflow",
"DemoProcess")